def __init__(self, *args, **kwargs): """ The logic of this constructor reflects a bit from legacy design patterns of `pfcon` -- specifically the passing of flags in a single structure, and the <self.state> dictionary to try and organize the space of <self> variables a bit logically. """ b_test = False d_args = {} str_desc = '' str_version = '' # pudb.set_trace() for k,v in kwargs.items(): if k == 'test': b_test = True if k == 'args': d_args = v if k == 'desc': str_desc = v if k == 'version': str_version = v self.s = D(*args, **kwargs) self.dp = pfmisc.debug( verbosity = S.T.cat('/this/verbosity'), within = S.T.cat('/this/name') ) self.pp = pprint.PrettyPrinter(indent=4)
def __init__(self, *args, **kwargs): """ Handler constructor """ global Gd_args, Gstr_description, Gstr_version, Gstr_name for k,v in kwargs.items(): if k == 'args': Gd_args = v if k == 'name': Gstr_name = v if k == 'desc': Gstr_description = v if k == 'version': Gstr_version = v self.storage = swiftStorage( args = Gd_args, name = Gstr_name, desc = Gstr_description, version = Gstr_version ) self.dp = pfmisc.debug( verbosity = int(Gd_args['verbosity']), within = S.T.cat('/this/name') ) BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, arg): """ Constructor. Defines a default report structure, divided into a "header" and a "body". In each section, DICOM tags retrieved from either the STUDY or SERIES level are catalogued. Since a given STUDY typically has several SERIES, in most cases only SERIES level tags are included in the "body". In some cases, some tags are only available at the SERIES level (such as the Modality). If such a tag is in the STUDY level, then the corresponding tag from the FIRST series in the STUDY is reported. """ # This is the main JSON object that contains # reports self.d_report: dict = {} super(Report, self).__init__(arg) self.reportTempate_construct(arg) self.dp = pfmisc.debug(verbosity=self.verbosity, within='Find', syslog=False) self.log = self.dp.qprint
def __init__(self, arg): """ Constructor. Largely simple/barebones constructor that calls the Base() and sets up the executable name. """ pudb.set_trace() self.l_files: list = [] # Check if an upstream 'reportData' exists, and if so # merge those args with the current namespace: if 'reportData' in arg.keys(): d_argCopy = arg.copy() # "merge" these 'arg's with upstream. arg.update(arg['reportData']['args']) # Since this might overwrite some args specific to this # app, we update again to the copy. arg.update(d_argCopy) super(Push, self).__init__(arg) self.dp = pfmisc.debug(verbosity=self.verbosity, within='Push', syslog=False) self.log = self.dp.qprint self.arg['name'] = "Push/PfStorage" self.swift = pfstorage.swiftStorage(args=self.arg)
def __init__(self, *args, **kwargs): """ Handler constructor """ # pudb.set_trace() b_initStateOnly = False for k, v in kwargs.items(): if k == 'initStateOnly': b_initStateOnly = bool(v) # Initialize the static class state directly in the # storage module pfstorage.swiftStorage.s = D(*args, **kwargs) self.__name__ = 'DCMhandler' self.b_useDebug = False self.str_debugFile = '/tmp/pacsretrieve.txt' self.b_quiet = True self.dcm = pfdcm(*args, **kwargs) self.dp = pfmisc.debug(verbosity=0, level=-1, within=self.__name__) self.pp = pprint.PrettyPrinter(indent=4) if not b_initStateOnly: super().__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): """ Constructor for FDG node. """ self.__name__ = "node" self.verbosity = -1 for k, v in kwargs.items(): if k == 'verbosity': self.verbosity = int(v) self.d_desc = { "id": "", "type": "circle", "score": 0.5, "group": 1, "size": 10 } self.l_connectedTo = [] self.dp = pfmisc.debug(verbosity=self.verbosity, level=-1, within=self.__name__) for k, v in kwargs.items(): if k == 'id': self.d_desc["id"] = v if k == 'type': self.d_desc["type"] = v if k == 'size': self.d_desc["size"] = int(v) if k == 'score': self.d_desc["score"] = float(v) if k == 'group': self.d_desc["group"] = int(v) if k == 'nodeInfo': self.d_desc = v self.dp.qprint('Node created: %s' % self, level=2)
def __init__(self, arg): """ Initialize some core self variables common to all derived classes. """ self.arg = arg self.defaults_init({ 'aet': 'CHRIS-AET', 'aec': 'CHRIS-AEC', 'serverIP': '127.0.0.1', 'serverPort': 4242, 'findscu': '/usr/bin/findscu', 'movescu': '/usr/bin/movescu', 'storescp': '/usr/bin/storescp', 'echoscu': '/usr/bin/echoscu', 'colorize': '', 'printReport': '', 'verbosity': 1, 'retrieve': False, 'move': False }) self.response = {'status': 'error', 'data': {}} self.dp = pfmisc.debug(verbosity=self.verbosity, within='Base', syslog=False)
def __init__(self, *args, **kwargs): """ """ global Gd_internalvar self.__auth = None self.__name__ = 'StoreHandler' self.d_ctlVar = Gd_internalvar b_test = False self.__b_tokenAuth = Gd_internalvar['b_tokenAuth'] self.b_useDebug = False self.str_debugFile = '/tmp/pfioh-log.txt' self.b_quiet = True self.dp = pfmisc.debug(verbosity=Gd_internalvar['verbosity'], within=self.__name__) self.pp = pprint.PrettyPrinter(indent=4) if self.__b_tokenAuth: self.__auth = Gd_internalvar['authModule'] for k, v in kwargs.items(): if k == 'test': b_test = True if k == 'tokenAuth': self.__b_tokenAuth = v if not b_test: BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, arg): """ Constructor. Nothing too fancy. Just a parent init and a class logging function. Most of the "complexity" here is "merging" upstream arg values with this specific app's arg values. """ # Check if an upstream 'reportData' exists, and if so # merge those args with the current namespace: if 'reportData' in arg.keys(): d_argCopy = arg.copy() # "merge" these 'arg's with upstream. arg.update(arg['reportData']['args']) # Since this might overwrite some args specific to this # app, we update again to the copy. arg.update(d_argCopy) super(Do, self).__init__(arg) self.dp = pfmisc.debug( verbosity = self.verbosity, within = 'Do', syslog = False ) self.log = self.dp.qprint
def __init__(self, **kwargs): """ A block to declare self variables """ self.str_desc = '' self.__name__ = "pyimgconvert" self.str_version = "1.0.10" self.verbosity = 1 self.dp = pfmisc.debug( verbosity = self.verbosity, within = self.__name__ ) # Directory and filenames self.str_inputDir = '' self.str_outputDir = '' self.str_args = '' self.str_inputFile = '' self.str_outputFile = '' for key, value in kwargs.items(): if key == "inputDir": self.str_inputDir = value if key == "outputDir": self.str_outputDir = value if key == "args": self.str_args = value if key == "inputFile": self.str_inputFile = value if key == "outputFile": self.str_outputFile = value
def __init__(self, **kwargs): def imageFileName_process(str_imageFile): b_OK = False l_indexAndFile = str_imageFile.split(':') if len(l_indexAndFile) == 1: b_OK = True self.str_outputImageFile = l_indexAndFile[0] if len(l_indexAndFile) == 2: b_OK = True self.str_outputImageFile = l_indexAndFile[1] self.str_imageIndex = l_indexAndFile[0] if not b_OK: self.dp.qprint("Invalid image specifier.", comms='error') error.fatal(self, 'imageFileSpecFail') if len(self.str_outputImageFile): self.b_convertToImg = True def tagList_process(str_tagList): self.str_tagList = str_tagList if len(self.str_tagList): self.b_tagList = True self.l_tag = self.str_tagList.split(',') def tagFile_process(str_tagFile): self.str_tagFile = str_tagFile if len(self.str_tagFile): self.b_tagFile = True with open(self.str_tagFile) as f: self.l_tag = [x.strip('\n') for x in f.readlines()] def outputFile_process(str_outputFile): self.str_outputFileType = str_outputFile self.l_outputFileType = self.str_outputFileType.split(',') # pudb.set_trace() self.declare_selfvars() for key, value in kwargs.items(): if key == "inputDir": self.str_inputDir = value if key == "inputFile": self.str_inputFile = value if key == "extension": self.str_extension = value if key == "outputDir": self.str_outputDir = value if key == "outputFileStem": self.str_outputFileStem = value if key == "outputFileType": outputFile_process(value) if key == 'printToScreen': self.b_printToScreen = value if key == 'imageFile': imageFileName_process(value) if key == 'tagFile': tagFile_process(value) if key == 'tagList': tagList_process(value) if key == 'verbosity': self.verbosityLevel = int(value) # Set logging self.dp = pfmisc.debug(verbosity=self.verbosityLevel, level=0, within=self.__name__) self.log = pfmisc.Message() self.log.syslog(True) if not len(self.str_inputDir): self.str_inputDir = '.'
def __init__(self, *args, **kwargs): """ Constructor, basically set some internal vars. """ self.__name__ = 'SMarkDown' self.verbosityLevel = 1 self.mdMarker = "_#_" self.dp = pfmisc.debug(verbosity=self.verbosityLevel, within=self.__name__)
def __init__(self, arg): """ Constructor. Defines a default report structure, divided into a "header" and a "body". In each section, DICOM tags retrieved from either the STUDY or SERIES level are catalogued. Since a given STUDY typically has several SERIES, in most cases only SERIES level tags are included in the "body". In some cases, some tags are only available at the SERIES level (such as the Modality). If such a tag is in the STUDY level, then the corresponding tag from the FIRST series in the STUDY is reported. """ b_reportSet = False if 'reportTags' in arg.keys(): if len(arg['reportTags']): self.d_reportTags = json.loads(arg['reportTags']) b_reportSet = True if not b_reportSet: self.d_reportTags = \ { "header": { "study" : [ "PatientName", "PatientBirthDate", "StudyDate", "PatientAge", "PatientSex", "AccessionNumber", "PatientID", "PerformedStationAETitle", "StudyDescription" ], "series": [ "Modality" ] }, "body": { "series" : [ "SeriesDescription" ] } } super(Find, self).__init__(arg) self.dp = pfmisc.debug(verbosity=self.verbosity, within='Find', syslog=False)
def __init__(self, arg): """ Constructor. Largely simple/barebones constructor that calls the Base() and sets up the executable name. """ super(Echo, self).__init__(arg) self.dp = pfmisc.debug(verbosity=self.verbosity, within='Echo', syslog=False)
def loggers_create(self): """ >>>>>>>>>>>>>> Debugging control <<<<<<<<<<<<<<<< Essentially we create some pfmisc.debug objects that write to files and also give them some shortcut names """ str_thisMRsession = pathlib.PurePath(self.args.str_xcrdir).name self.str_pulseFile = '%s/%s-pulse.log' % (self.args.str_logDir, str_thisMRsession) self.str_debugFile = '%s/repack.log' % self.args.str_logDir self.pulseObj = pfmisc.debug(verbosity=int(self.args.verbosity), level=2, within=self.__name__, debugToFile=self.args.b_debug, debugFile=self.str_pulseFile) self.dp = pfmisc.debug(verbosity=int(self.args.verbosity), level=2, within=self.__name__, debugToFile=self.args.b_debug, debugFile=self.str_debugFile) self.logPulse = self.pulseObj.qprint self.log = self.dp.qprint
def __init__(self, **kwargs): """ A "base" class for all pfdicom objects. This class is typically never called/used directly; derived classes are used to provide actual end functionality. This class really only reads in a DICOM file, and populates some internal convenience member variables. Furthermore, this class does not have a concept nor concern about "output" relations. """ def outputDir_process(str_outputDir): if str_outputDir == '%inputDir': self.str_outputDir = self.str_inputDir else: self.str_outputDir = str_outputDir # pudb.set_trace() pfdicom.declare_selfvars(self) for key, value in kwargs.items(): if key == 'inputDir': self.str_inputDir = value if key == 'maxDepth': self.maxDepth = int(value) if key == 'inputFile': self.str_inputFile = value if key == "outputDir": outputDir_process(value) if key == 'outputFileStem': self.str_outputFileStem = value if key == 'outputLeafDir': self.str_outputLeafDir = value if key == 'extension': self.str_extension = value if key == 'threads': self.numThreads = int(value) if key == 'extension': self.str_extension = value if key == 'verbosity': self.verbosityLevel = int(value) if key == 'json': self.b_json = bool(value) if key == 'followLinks': self.b_followLinks = bool(value) # Declare pf_tree self.pf_tree = pftree.pftree(inputDir=self.str_inputDir, maxDepth=self.maxDepth, inputFile=self.str_inputFile, outputDir=self.str_outputDir, outputLeafDir=self.str_outputLeafDir, threads=self.numThreads, verbosity=self.verbosityLevel, followLinks=self.b_followLinks, relativeDir=True) # Set logging self.dp = pfmisc.debug(verbosity=self.verbosityLevel, within=self.__name__) self.log = pfmisc.Message() self.log.syslog(True)
def __init__(self, *args, **kwargs): """ Constructor for pftreeDo. """ self.args = args[0] # The 'self' isn't fully instantiated, so # we call the following method on the class # directly. pfdo.declare_selfvars(self) self.dp = pfmisc.debug(verbosity=int(self.args['verbosity']), within=self.__name__)
def __init__(self, arg): """ Constructor. Largely simple/barebones constructor that calls the Base() and sets up the executable name. """ super(Status, self).__init__(arg) self.dp = pfmisc.debug(verbosity=self.verbosity, within='Find', syslog=False) self.log = self.dp.qprint self.db = smdb.SMDB(Namespace(str_logDir=self.arg['dblogbasepath']))
def __init__(self, *args, **kwargs): """ Class constructor. """ self.d_args = vars(*args) self.state = D(version=str_version, name=str_name, desc=str_desc, args=vars(*args)) self.dp = pfmisc.debug(verbosity=int(self.d_args['verbosity']), within=str_name, syslog=self.d_args['b_syslog']) # Check the IP in the state structure and optionally update IP = self.S('/CUBE/address') if IP == "%HOSTIP": self.S('/CUBE/address', str_defIP)
def __init__(self, arg, *args, **kwargs): """ The logic of this constructor reflects a bit from legacy design patterns of `pfcon` -- specifically the passing of flags in a single structure, and the <self.state> dictionary to try and organize the space of <self> variables a bit logically. """ # pudb.set_trace() self.arg = arg self.S = D(arg, *args, **kwargs) self.dp = pfmisc.debug( verbosity = self.state('/this/verbosity'), within = self.state('/this/name') ) self.log = self.dp.qprint
def __init__(self, args): self.__name__ = 'Listen' self.tmp_directory = args['tmp_directory'] self.log_directory = args['log_directory'] self.data_directory = args['data_directory'] self.executable = args['executable'] # Debugging control self.b_useDebug = True self.str_debugFile = '%s/listen.run.log' % self.log_directory self.b_quiet = True self.dp = pfmisc.debug(verbosity=0, level=-1, within=self.__name__, debugToFile=self.b_useDebug, debugFile=self.str_debugFile) self.dp.qprint( '───────────────────────────────────────────────────────────────────────────', level=-1) self.dp.qprint('Incoming DICOM data arriving...', level=-1) # maybe it should not create it, as it is a requirement os.makedirs(self.tmp_directory, exist_ok=True) os.makedirs(self.log_directory, exist_ok=True) os.makedirs(self.data_directory, exist_ok=True) self.series_mapDir = os.path.join(self.log_directory, 'series_map') self.study_mapDir = os.path.join(self.log_directory, 'study_map') self.patient_mapDir = os.path.join(self.log_directory, 'patient_map') os.makedirs(self.series_mapDir, exist_ok=True) os.makedirs(self.study_mapDir, exist_ok=True) os.makedirs(self.patient_mapDir, exist_ok=True) # create unique directory to store inconming data self.uuid = str(uuid.uuid4()) self.uuid_directory = os.path.join(self.tmp_directory, self.uuid) self.log_error = os.path.join(self.log_directory, 'err-' + self.uuid + '.txt') self.log_output = os.path.join(self.log_directory, 'out-' + self.uuid + '.txt') self.dp.qprint('Creating temp holding dir: %s' % self.uuid_directory, level=-1) self.mkdir(self.uuid_directory, self.log_error)
def __init__(self, args): self.__name__ = 'Listen' self.tmp_directory = args['tmp_directory'] self.log_directory = args['log_directory'] self.data_directory = args['data_directory'] if 'executable' in args: self.executable = args['executable'] else: self.executable = 'storescp' # Debugging control self.b_useDebug = True self.str_debugFile = '%s/listen.run.log' % self.log_directory self.b_quiet = True self.dp = pfmisc.debug(verbosity=0, level=-1, within=self.__name__, debugToFile=self.b_useDebug, debugFile=self.str_debugFile) self.pp = pprint.PrettyPrinter(indent=4) self.dp.qprint('Called!') # maybe it should not create it, as it is a requirement os.makedirs(self.tmp_directory, exist_ok=True) os.makedirs(self.log_directory, exist_ok=True) os.makedirs(self.data_directory, exist_ok=True) self.series_mapDir = os.path.join(self.log_directory, 'series_map') self.study_mapDir = os.path.join(self.log_directory, 'study_map') self.patient_mapDir = os.path.join(self.log_directory, 'patient_map') os.makedirs(self.series_mapDir, exist_ok=True) os.makedirs(self.study_mapDir, exist_ok=True) os.makedirs(self.patient_mapDir, exist_ok=True) # create unique directory to store inconming data self.uuid = str(uuid.uuid4()) self.uuid_directory = os.path.join(self.tmp_directory, self.uuid) self.log_error = os.path.join(self.log_directory, 'err-' + self.uuid + '.txt') self.log_output = os.path.join(self.log_directory, 'out-' + self.uuid + '.txt') self.mkdir(self.uuid_directory, self.log_error)
def debugloggers_create(self): """ Create the loggers. """ if 'verbosity' not in self.args: self.args.verbosity = 0 if 'b_debug' not in self.args: self.args.b_debug = False if 'str_debugFile' not in self.args: self.args.str_debugFile = '/dev/null' self.str_debugFile = '%s/smdb.log' % self.args.str_logDir self.dp = pfmisc.debug(verbosity=int(self.args.verbosity), level=2, within=self.__name__, debugToFile=self.args.b_debug, debugFile=self.str_debugFile) self.log = self.dp.qprint
def __init__(self, d_meta, *args, **kwargs): """ Class constructor. """ # Structures to contain the "CLI" of the plugin # to be scheduled/run self.d_args : dict = vars(*args) self.d_CLIargs : dict = {} self.d_CLIvals : dict = {} self.d_CLItemplate : dict = {} # Some additional "massaging" from these CLI # to CLI appropriate for the search module: self.d_args['str_using'] = self.d_args['str_pluginSpec'] self.d_args['str_for'] = 'id' ns = Namespace(**self.d_args) # The search module -- used to determine the plugin ID # in ChRIS/CUBE self.query = search.PluginSearch(d_meta, ns) self.str_pluginID : str = '' # Generic "state" data, mostly describing the # compute environment in which CUBE exists self.d_meta = d_meta self.state = D( version = d_meta['version'], name = d_meta['name'], desc = d_meta['desc'], args = vars(*args) ) # A debug/print object self.dp = pfmisc.debug( verbosity = int(self.d_args['verbosity']), within = d_meta['name'], syslog = self.d_args['b_syslog'], colorize = self.state.T.cat('/this/colorize') ) # Quick housekeeping self.CUBE_IPspec()
def __init__(self, *args, **kwargs): """ """ global Gd_internalvar self.__name__ = 'StoreHandler' self.d_ctlVar = Gd_internalvar b_test = False self.b_useDebug = False self.str_debugFile = '/tmp/pfioh-log.txt' self.b_quiet = True self.dp = pfmisc.debug(verbosity=0, level=-1, within=self.__name__) self.pp = pprint.PrettyPrinter(indent=4) for k, v in kwargs.items(): if k == 'test': b_test = True if not b_test: BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): """ Constructor for FDG class -- this is collection of nodes that are saved to a JSON representation. """ self.__name__ = 'FDG' self.verbosity = -1 for k, v in kwargs.items(): if k == 'verbosity': self.verbosity = int(v) # nodelist vars self.d_mesh = {} # The whole mesh containing # the dict of nodes and # the dict of links self.d_nodeNeighbor = {} # dict of each node's # neighbors self.d_nodes = {} # dict containing the... self.ld_nodes = [] # ... list of dict nodes self.l_Node = [] # a list of node objects self.lstr_nodeID = [] # a similarly indexed list # of node names self.l_nodeID = [] self.d_links = {} # dict containing the... self.ld_links = [] # ... list of dict links # save file self.str_saveFile = '' self.dp = pfmisc.debug(verbosity=self.verbosity, level=-1, within=self.__name__) # per-node variables NodeDummy = Node() self.d_nodeLine = NodeDummy.d_desc
def __init__(self, *args, **kwargs): """ Constructor for Mesh class """ self.__name__ = 'Mesh' # General mesh characteristics self.spokes = 2 self.nodes = 10 # nodelist vars self.d_mesh = {} # The whole mesh containing the ... # ... dict of nodes and dict of links self.d_nodeNeighbor = {} # dict of each node's neighbors self.d_nodes = {} # dict containing the... self.ld_nodes = [] # ... list of dict nodes self.l_nodes = [] # Just a list of node indices self.d_links = {} # dict containing the... self.ld_links = [] # ... list of dict links self.str_groupSpread = 'uniform' self.str_prefix = '' self.groupID = 1 self.increment = 1 # save file self.str_saveFile = '' self.dp = pfmisc.debug(verbosity=0, level=-1, within=self.__name__) for k, v in kwargs.items(): if k == 'spokes': self.spokes = v if k == 'nodes': self.nodes = v self.dp.qprint('Creating node list of %d nodes...' % self.nodes) self.l_nodes = list(range(self.nodes)) self.d_nodeNeighbor = dict(enumerate(self.l_nodes))
def __init__(self, d_meta, *args, **kwargs): """ Class constructor. """ self.d_args = vars(*args) self.state = D(version=d_meta['version'], name=d_meta['name'], desc=d_meta['desc'], args=vars(*args)) if 'verbosity' in self.d_args: verbosity = self.d_args['verbosity'] else: verbosity = 0 if 'b_syslog' in self.d_args: b_syslog = self.d_args['b_syslog'] else: b_syslog = False self.dp = pfmisc.debug(verbosity=int(verbosity), within=d_meta['name'], syslog=b_syslog, colorize=self.state.T.cat('/this/colorize')) # Check the IP in the state structure and optionally update IP = self.S('/CUBE/address') if IP == "%HOSTIP": self.S('/CUBE/address', d_meta['defIP'])
def __init__(self, **kwargs): # pudb.set_trace() self.declare_selfvars() for key, value in kwargs.items(): if key == 'inputDir': self.str_inputDir = value if key == 'maxDepth': self.maxdepth = int(value) if key == 'inputFile': self.str_inputFile = value if key == 'outputDir': self.str_outputDir = value if key == 'verbosity': self.verbosityLevel = int(value) if key == 'threads': self.numThreads = int(value) if key == 'relativeDir': self.b_relativeDir = bool(value) if key == 'stats': self.b_stats = bool(value) if key == 'statsReverse': self.b_statsReverse = bool(value) if key == 'jsonStats': self.b_jsonStats = bool(value) if key == 'json': self.b_json = bool(value) if key == 'followLinks': self.b_followLinks = bool(value) if key == 'test': self.str_sleepLength = value if key == 'outputLeafDir': self.str_outputLeafDir = value if len(self.str_sleepLength): l_test = self.str_sleepLength.split(':') self.str_sleepLength = l_test[0] if len(l_test) == 2: self.testType = int(l_test[1]) try: self.f_sleepLength = float(self.str_sleepLength) self.b_test = True except: self.b_test = False # Set logging self.dp = pfmisc.debug(verbosity=self.verbosityLevel, within=self.__name__) self.log = pfmisc.Message() self.log.syslog(True) if not len(self.str_inputDir): self.str_inputDir = '.'
def __init__(self, *args, **kwargs): ChrisApp.__init__(self, *args, **kwargs) self.__name__ = 'PacsQueryApp' # Debugging control self.b_useDebug = False self.str_debugFile = '/dev/null' self.b_quiet = True self.dp = pfmisc.debug( verbosity = 0, level = -1, within = self.__name__ ) self.pp = pprint.PrettyPrinter(indent=4) # Output dir self.str_outputDir = '' # Service and payload vars self.str_pfdcm = '' self.str_msg = '' self.d_msg = {} # Alternate, simplified CLI flags self.str_patientID = '' self.str_PACSservice = '' # Control self.b_canRun = False # Summary report self.b_summaryReport = False self.str_summaryKeys = '' self.l_summaryKeys = [] self.str_summaryFile = '' # Result report self.str_resultFile = ''
def __init__(self, *args, **kwargs): """ """ global Gd_internalvar self.__name__ = 'StoreHandler' self.d_ctlVar = Gd_internalvar b_test = False self.b_useDebug = False self.str_debugFile = '/tmp/pfioh-log.txt' self.b_quiet = True self.dp = pfmisc.debug( verbosity = 0, level = -1, within = self.__name__ ) self.pp = pprint.PrettyPrinter(indent=4) for k,v in kwargs.items(): if k == 'test': b_test = True if not b_test: BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def __init__(self, **kwargs): # threading.Thread.__init__(self) self._log = Message() self._log._b_syslog = True self.__name__ = "Charm" self.b_useDebug = settings.CHRIS_DEBUG['useDebug'] str_debugDir = '%s/tmp' % os.environ['HOME'] if not os.path.exists(str_debugDir): os.makedirs(str_debugDir) self.str_debugFile = '%s/debug-charm.log' % str_debugDir if len(settings.CHRIS_DEBUG['debugFile']): self.str_debugFile = settings.CHRIS_DEBUG['debugFile'] self.str_http = "" self.str_ip = "" self.str_port = "" self.str_URL = "" self.str_verb = "" self.str_msg = "" self.d_msg = {} self.str_protocol = "http" self.dp = pfmisc.debug( verbosity = 1, within = self.__name__ ) self.pp = pprint.PrettyPrinter(indent=4) self.b_man = False self.str_man = '' self.b_quiet = settings.CHRIS_DEBUG['quiet'] self.b_raw = False self.auth = '' self.str_jsonwrapper = '' self.str_IOPhost = '' self.str_cmd = '' self.str_inputdir = '' self.str_outputdir = '' self.d_args = {} self.l_appArgs = {} self.c_pluginInst = {'contents': 'void'} self.app = None self.LC = 40 self.RC = 40 for key, val in kwargs.items(): if key == 'app_args': self.l_appArgs = val if key == 'd_args': self.d_args = val if key == 'plugin_inst': self.c_pluginInst = val if key == 'app': self.app = val if key == 'inputdir': self.str_inputdir = val if key == 'outputdir': self.str_outputdir = val if key == 'useDebug': self.b_useDebug = val if key == 'debugFile': self.str_debugFile = val if key == 'quiet': self.b_quiet = val if key == 'IOPhost': self.str_IOPhost = val if self.b_useDebug: self.debug = Message(logTo = self.str_debugFile) self.debug._b_syslog = True self.debug._b_flushNewLine = True if self.b_quiet: self.dp.verbosity = -10 # This for the case when Charm is instantiated w/o a plugin instance, eg # as a dispatcher to simply send a pfcon instance a message. try: self.d_pluginInst = vars(self.c_pluginInst) except: self.d_pluginInst = {} # pudb.set_trace() if not self.b_quiet: str_desc = Colors.CYAN + """ +---------------------+ | Welcome to charm! | +---------------------+ """ + Colors.LIGHT_GREEN + """ 'charm' is the interface class/code between ChRIS and a remote REST-type server, typically 'pfcon'. This module is the only contact boundary between ChRIS and external/remote services. Debugging output is currently sent to """ + Colors.YELLOW if self.b_useDebug: str_desc += "'" + self.str_debugFile +"'" else: str_desc += "*this* console" str_desc += Colors.NO_COLOUR self.dp.qprint(str_desc) self.dp.qprint('d_args = %s' % self.pp.pformat(self.d_args).strip()) self.dp.qprint('app_args = %s' % self.l_appArgs) self.dp.qprint('d_pluginInst = %s' % self.pp.pformat(self.d_pluginInst).strip()) self.dp.qprint('app = %s' % self.app) self.dp.qprint('inputdir = %s' % self.str_inputdir) self.dp.qprint('outputdir = %s' % self.str_outputdir)
def __init__(self, **kwargs): """ Initial object, set control and other flags. :param kwargs: """ self.b_shell = True self.b_showStdOut = True self.b_showStdErr = True self.b_echoCmd = False # Debugging self.verbosity = 1 # Toggle special handling of "compound" jobs self.l_cmd = [] self.b_splitCompound = True self.b_syncMasterSlave = True # If True, sub-commands will pause # after complete and need to be # explicitly told to continue by # master. The master needs to monitor # internal state to know when a thread # is waiting to be told to continue. # Queues for communicating between threads self.queue_startEvent = Queue() self.queue_endEvent = Queue() # Queues for extracting specific information # Separate queues for <start> and <end> events need to be maintained self.queue_pid = Queue() self.queueStart_pid = Queue() self.queueEnd_pid = Queue() self.queue_continue = Queue() self.queue = Queue() # Job info # Each job executed is stored in a list of # dictionaries. self.jobCount = 0 self.jobTotal = -1 self.d_job = {} self.d_fjob = {} self.b_synchronized = False self.b_jobsAllDone = False self.jid = '' self.auid = '' # Threads for job control and execution self.t_ctl = None # Controller thread self.t_exe = None # Exe thread self.pp = pprint.PrettyPrinter(indent=4) str_debugFile = '' b_debugToFile = False for key, val in kwargs.items(): if key == 'verbosity': self.verbosity = val if key == 'debugFile': str_debugFile = val if key == 'debugToFile': b_debugToFile = val self.debug = pfmisc.debug( verbosity = self.verbosity, debugFile = str_debugFile, debugToFile = b_debugToFile, within = 'crunner')