<commit_before># 
# Copyright 2012-2014 University of Southern California
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import cStringIO
import web
import json
import cxi

class Printer:
    def __init__(self):
        self.uri = 'http://purl.org/usc-microscopy'
        self.CXI_RET = 'Return value'
        self.CXI_MSG = 'Return Message'
        
    def setPrinter(self, id, printer):
        if self.printers != None:
            if id == 'Specimen':
                self.printer_id, self.printer_port = (self.printers['box_addr'], self.printers['box_port'])
            elif id == 'Slide':
                self.printer_id, self.printer_port = (self.printers['slide_addr'], self.printers['slide_port'])
        
        printer_id, printer_port = printer
        
        if printer_id != None:
            self.printer_id = printer_id
        if printer_port != None:
            self.printer_port = printer_port
        
class PrintControl (Printer):
    
    def __init__(self):
        Printer.__init__(self)
        
    def GET(self, printerID, param):
        printer = web.input()
        printer_id = None
        printer_port = None
        try:
           printer_id = printer['printer_id']
        except:
            pass
           
        try:
           printer_port = int(printer['printer_port'])
        except:
            pass
           
        self.setPrinter(printerID, (printer_id, printer_port))
        response = []
        try:
            if param == 'getStatus':
                res = cxi.utils.checkStatus(self.printer_id, self.printer_port)
            elif param == 'getConfiguration':
                res = cxi.utils.checkConfig(self.printer_id, self.printer_port)
        except:
            res = {}
            res[self.CXI_RET] = 0
            res[self.CXI_MSG] = 'Internal Server Error. The request execution encountered a runtime error.'<commit_msg>Enable also the "Check Connection" GET request.<commit_after># 
# Copyright 2012-2014 University of Southern California
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import cStringIO
import web
import json
import cxi

class Printer:
    def __init__(self):
        self.uri = 'http://purl.org/usc-microscopy'
        self.CXI_RET = 'Return value'
        self.CXI_MSG = 'Return Message'
        
    def setPrinter(self, id, printer):
        if self.printers != None:
            if id == 'Specimen':
                self.printer_id, self.printer_port = (self.printers['box_addr'], self.printers['box_port'])
            elif id == 'Slide':
                self.printer_id, self.printer_port = (self.printers['slide_addr'], self.printers['slide_port'])
        
        printer_id, printer_port = printer
        
        if printer_id != None:
            self.printer_id = printer_id
        if printer_port != None:
            self.printer_port = printer_port
        
class PrintControl (Printer):
    
    def __init__(self):
        Printer.__init__(self)
        
    def GET(self, printerID, param):
        printer = web.input()
        printer_id = None
        printer_port = None
        try:
           printer_id = printer['printer_id']
        except:
            pass
           
        try:
           printer_port = int(printer['printer_port'])
        except:
            pass
           
        self.setPrinter(printerID, (printer_id, printer_port))
        response = []
        try:
            if param == 'getStatus':
                res = cxi.utils.checkStatus(self.printer_id, self.printer_port)
            elif param == 'getConfiguration':
                res = cxi.utils.checkConfig(self.printer_id, self.printer_port)
            elif param == 'checkConnection':
                res = cxi.utils.checkConnection(self.printer_id, self.printer_port)
        except:
            res = {}
            res[self.CXI_RET] = 0
            res[self.CXI_MSG] = 'Internal Server Error. The request execution encountered a runtime error.'
{'fraction_non_alphanumeric': 0.09144008056394763, 'fraction_numerical': 0.0052366565961732125, 'mean_word_length': 2.191516709511568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '90614', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1395, 'n_words': 405}