def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='FOIA Patch Sequence Analyzer', parents=[testClientParser]) parser.add_argument('-p', '--patchFileDir', required=True, help='input file path to the folder that contains all the FOIA patches') parser.add_argument('-l', '--logDir', required=True, help='Output dirctory to store all log file information') parser.add_argument('-i', '--install', default=False, action="store_true", help = 'whether to install Patch or not') group = parser.add_mutually_exclusive_group() group.add_argument('-n', '--numOfPatch', default=1, help="input All for all patches, " "otherwise just enter number, default is 1") group.add_argument('-u', '--upToPatch', help="install patches up to specified install name") group.add_argument('-o', '--onlyPatch', help='install specified patch and required patches only' ', this option will ignore the CSV dependencies') parser.add_argument('-d', '--duz', default=17, type=int, help='installer\'s VistA instance\'s DUZ') result = parser.parse_args(); print (result) inputPatchDir = result.patchFileDir assert os.path.exists(inputPatchDir) outputDir = result.logDir assert os.path.exists(outputDir) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) testClient2 = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient initConsoleLogging() with testClient as vistAClient: patchSeqApply = PatchSequenceApply(vistAClient, outputDir) patchSeqApply._duz = result.duz assert testClient2 with testClient2 as vistAClient2: patchSeqApply._testClient2 = vistAClient2 if result.upToPatch: patchSeqApply.generatePatchSequence(inputPatchDir, result.upToPatch, True) else: patchSeqApply.generatePatchSequence(inputPatchDir, result.onlyPatch) if result.install: if result.onlyPatch: patchSeqApply.applyPatchSequenceByNumber("All") elif result.upToPatch: patchSeqApply.applyPatchSequenceByInstallName(result.upToPatch) else: patchSeqApply.applyPatchSequenceByNumber(result.numOfPatch)
def testMountDisMountLocalDb(): from VistATestClient import createTestClientArgParser from VistATestClient import VistATestClientFactory testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser( description='InterSystem Cache Mount Dismount Test', parents=[testClientParser]) parser.add_argument('-p', '--dirPath', required=True, help='Enter directory path for the local database') parser.add_argument( '-a', '--action', choices=['M', 'D'], required=True, type=str, help='M: mount the database, D: dismount the database. ' 'Make sure InterSystem ^DATABASE routine is accessable via' ' specified namespace.') result = parser.parse_args() print(result) testClient = VistATestClientFactory.createVistATestClientWithArgs(result) with testClient: if result.action == 'D': logging.info('Dismount LocalDB: %s' % result.dirPath) dismountLocalDatabase(result.dirPath, testClient) else: logging.info('mount LocalDB: %s' % result.dirPath) mountLocalDatabase(result.dirPath, testClient)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='Default KIDS Installer', parents=[testClientParser]) parser.add_argument('kidsFile', metavar='K', help='path to KIDS Build file') parser.add_argument('installName', metavar='I', help='kids install name') parser.add_argument('-l', '--logFile', default=None, help='path to logFile') parser.add_argument('-r', '--reinstall', default=False, action='store_true', help='whether re-install the KIDS even it is already installed') parser.add_argument('-m', '--multiBuildList', default=None, nargs='*', help='list of multibuild install names') parser.add_argument('-g', '--globalFiles', default=None, nargs='*', help='list of global files that need to import') result = parser.parse_args(); print (result) testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient initConsoleLogging() with testClient: kidsFile = os.path.abspath(result.kidsFile) defaultKidsInstall = DefaultKIDSPatchInstaller(kidsFile, result.installName, logFile=result.logFile, multiBuildList=result.multiBuildList, globals=result.globalFiles) defaultKidsInstall.runInstallation(testClient, result.reinstall)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA M Component Extractor', parents=[testClientParser]) parser.add_argument('-o', '--outputDir', required=True, help='output Dir to store global/routine export files') parser.add_argument('-r', '--vistARepo', required=True, help='path to the top directory of VistA-M repository') parser.add_argument( '-l', '--logDir', required=True, help='path to the top directory to store the log files') parser.add_argument( '-ro', '--routineOutDir', default=None, help='path to the directory where GT. M stores routines') result = parser.parse_args() print(result) outputDir = result.outputDir assert os.path.exists(outputDir) initConsoleLogging() """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: vistADataExtractor = VistADataExtractor(result.vistARepo, outputDir, result.logDir, result.routineOutDir) vistADataExtractor.extractData(testClient)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Data Extractor', parents=[testClientParser]) parser.add_argument('-o', '--outputDir', required=True, help='output Dir to store global/routine export files') parser.add_argument('-r', '--vistARepo', required=True, help='path to the top directory of VistA-FOIA repository') parser.add_argument('-l', '--logDir', required=True, help='path to the top directory to store the log files') parser.add_argument('-ro', '--routineOutDir', default=None, help='path to the directory where GT. M stores routines') result = parser.parse_args(); print (result) outputDir = result.outputDir assert os.path.exists(outputDir) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: vistADataExtractor = VistADataExtractor(result.vistARepo, outputDir, result.logDir, result.routineOutDir) vistADataExtractor.extractData(testClient)
def createTestClient(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description="VistA Patch Info Query", parents=[testClientParser]) result = parser.parse_args() print (result) testClient = VistATestClientFactory.createVistATestClientWithArgs(result) return testClient
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='FOIA Patch Sequence Analyzer', parents=[testClientParser]) parser.add_argument('-f', '--foiaBranch', required=True, help='input the branch name from which the global files are downloaded') parser.add_argument('-r', '--foiaRemote', required=False, default="https://raw.githubusercontent.com/OSEHRA-Sandbox/VistA-M/", help='input the VistA-M repository from which the global files are downloaded, must be a link to the raw data.\ Default remote is: https://raw.githubusercontent.com/OSEHRA-Sandbox/VistA-M/ ') parser.add_argument('-t', '--tmpDir', required=True, help='input the filepath to a directory to download the necessary global files') parser.add_argument('-g', '--gtmDir', required=False, help='input the filepath to a directory where GT.M stores its routines') parser.add_argument('-i', '--install', required=False, action="store_true", help='Attempt to install global files with ^ZGI?') parser.add_argument('-l', '--log', required=False, help='File to which I would log VistA communication') result = parser.parse_args(); """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient initConsoleLogging() if result.log: testClient.setLogFile(result.log) with testClient as vistaClient: update = updateMFSGlobals() update.updateMFSGlobalFiles(vistaClient,result.foiaBranch, result.foiaRemote,result.tmpDir, result.gtmDir, result.install)
def testMountDisMountLocalDb(): from VistATestClient import createTestClientArgParser from VistATestClient import VistATestClientFactory testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description="InterSystem Cache Mount Dismount Test", parents=[testClientParser]) parser.add_argument("-p", "--dirPath", required=True, help="Enter directory path for the local database") parser.add_argument( "-a", "--action", choices=["M", "D"], required=True, type=str, help="M: mount the database, D: dismount the database. " "Make sure InterSystem ^DATABASE routine is accessable via" " specified namespace.", ) result = parser.parse_args() print result testClient = VistATestClientFactory.createVistATestClientWithArgs(result) with testClient: if result.action == "D": logging.info("Dismount LocalDB: %s" % result.dirPath) dismountLocalDatabase(result.dirPath, testClient) else: logging.info("mount LocalDB: %s" % result.dirPath) mountLocalDatabase(result.dirPath, testClient)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA M Component Extractor', parents=[testClientParser]) parser.add_argument('-o', '--outputDir', required=True, help='output Dir to store global/routine export files') parser.add_argument('-r', '--vistARepo', required=True, help='path to the top directory of VistA-M repository') parser.add_argument('-l', '--logDir', required=True, help='path to the top directory to store the log files') parser.add_argument('-ro', '--routineOutDir', default=None, help='path to the directory where GT. M stores routines') parser.add_argument('-sx', '--serialize', default=False, action="store_true", help = 'export the globals serially (Needed on on single-user Cache instace)') result = parser.parse_args(); print (result) outputDir = result.outputDir assert os.path.exists(outputDir) initConsoleLogging() """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: vistADataExtractor = VistADataExtractor(result.vistARepo, outputDir, result.logDir, result.routineOutDir, serialExport = result.serialize) vistADataExtractor.extractData(testClient)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Routine Export', parents=[testClientParser]) parser.add_argument('-o', '--outputFile', help='Output File Name to store routine export information') parser.add_argument('-a', '--allRoutines', action="store_true", default=False, help='export all routines') parser.add_argument('-r', '--routines', nargs='*', help='only specified routine names') parser.add_argument('-e', '--exclude', nargs='*', default=None, help='exclude specified routine names') result = parser.parse_args(); print (result) outputFilename = result.outputFile outputDir = os.path.dirname(outputFilename) assert os.path.exists(outputDir) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile(DEFAULT_OUTPUT_LOG_FILE_NAME) print "Log File is %s" % logFilename vistAClient.setLogFile(logFilename) isAllRoutines = result.allRoutines vistARoutineExport = VistARoutineExport() if isAllRoutines: vistARoutineExport.exportAllRoutines(vistAClient, outputFilename, result.exclude) else: vistARoutineExport.exportRoutines(vistAClient, outputFilename, result.routines, result.exclude)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='Default KIDS Installer', parents=[testClientParser]) parser.add_argument('kidsFile', help='path to KIDS Build file') parser.add_argument('-l', '--logFile', default=None, help='path to logFile') parser.add_argument('-r', '--reinstall', default=False, action='store_true', help='whether re-install the KIDS even it is already installed') parser.add_argument('-g', '--globalFiles', default=None, nargs='*', help='list of global files that need to import') result = parser.parse_args(); print (result) testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient initConsoleLogging() with testClient: kidsFile = os.path.abspath(result.kidsFile) from KIDSBuildParser import KIDSBuildParser kidsParser = KIDSBuildParser(None) kidsParser.unregisterSectionHandler(KIDSBuildParser.ROUTINE_SECTION) kidsParser.parseKIDSBuild(kidsFile) installNameList = kidsParser.installNameList installName = installNameList[0] multiBuildList = installNameList if len(installNameList) == 1: multiBuildList = None defaultKidsInstall = DefaultKIDSBuildInstaller(kidsFile, installName, logFile=result.logFile, multiBuildList=multiBuildList, globals=result.globalFiles) defaultKidsInstall.runInstallation(testClient, result.reinstall)
def createTestClient(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description="Default KIDS Installer", parents=[testClientParser]) result = parser.parse_args() print(result) testClient = VistATestClientFactory.createVistATestClientWithArgs(result) return testClient
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='FOIA Patch Sequence Analyzer', parents=[testClientParser]) parser.add_argument('-p', '--patchFileDir', required=True, help='input file path to the folder that contains all the FOIA patches') parser.add_argument('-l', '--logDir', required=True, help='Output dirctory to store all log file information') parser.add_argument('-i', '--install', default=False, action="store_true", help = 'whether to install KIDS Patch or not') parser.add_argument('-n', '--numOfPatch', required=False, default=1, help="input All for all patches, otherwise just enter number, default is 1") result = parser.parse_args(); print (result) inputPatchDir = result.patchFileDir assert os.path.exists(inputPatchDir) outputDir = result.logDir assert os.path.exists(outputDir) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: kidsPatchApply = KIDSPatchSequenceApply(vistAClient, outputDir) kidsPatchApply.generateKIDSPatchSequence(inputPatchDir) if result.install: kidsPatchApply.applyKIDSPatchSequence(result.numOfPatch)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description="VistA Routine Export", parents=[testClientParser]) parser.add_argument("-o", "--outputFile", help="Output File Name to store routine export information") parser.add_argument("-a", "--allRoutines", action="store_true", default=False, help="export all routines") parser.add_argument("-r", "--routines", nargs="*", help="only specified routine names") parser.add_argument("-e", "--exclude", nargs="*", default=None, help="exclude specified routine names") result = parser.parse_args() print (result) outputFilename = result.outputFile outputDir = os.path.dirname(outputFilename) assert os.path.exists(outputDir) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile() print "Log File is %s" % logFilename vistAClient.setLogFile(logFilename) isAllRoutines = result.allRoutines vistARoutineExport = VistARoutineExport() if isAllRoutines: vistARoutineExport.exportAllRoutines(vistAClient, outputFilename, result.exclude) else: vistARoutineExport.exportRoutines(vistAClient, outputFilename, result.routines, result.exclude)
def main(): import logging initConsoleLogging(logging.INFO) testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Taskman Utilities', parents=[testClientParser]) parser.add_argument( '-a', '--action', required=True, choices=['Start', 'Stop', 'Shutdown'], help= 'Start:Start Taskman, Stop:Stop Taskman, Shutdown:Shutdown all tasks') result = parser.parse_args() print result """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile() print "Log File is %s" % logFilename vistAClient.setLogFile(logFilename) taskmanUtil = VistATaskmanUtil() actionMap = { "Start": taskmanUtil.startTaskman, "Stop": taskmanUtil.stopTaskman, "Shutdown": taskmanUtil.shutdownAllTasks } actionMap[result.action](vistAClient)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser( description='FOIA Patch Sequence Analyzer', parents=[testClientParser]) parser.add_argument( '-p', '--patchFileDir', required=True, help='input file path to the folder that contains all the FOIA patches' ) parser.add_argument( '-l', '--logDir', required=True, help='Output dirctory to store all log file information') parser.add_argument('-i', '--install', default=False, action="store_true", help='whether to install Patch or not') group = parser.add_mutually_exclusive_group() group.add_argument('-n', '--numOfPatch', default=1, help="input All for all patches, " "otherwise just enter number, default is 1") group.add_argument('-u', '--upToPatch', help="install patches up to specified install name") group.add_argument('-o', '--onlyPatch', help='install specified patch and required patches only' ', this option will ignore the CSV dependencies') result = parser.parse_args() print(result) inputPatchDir = result.patchFileDir assert os.path.exists(inputPatchDir) outputDir = result.logDir assert os.path.exists(outputDir) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient initConsoleLogging() with testClient as vistAClient: patchSeqApply = PatchSequenceApply(vistAClient, outputDir) if result.upToPatch: patchSeqApply.generatePatchSequence(inputPatchDir, result.upToPatch, True) else: patchSeqApply.generatePatchSequence(inputPatchDir, result.onlyPatch) if result.install: if result.onlyPatch: patchSeqApply.applyPatchSequenceByNumber("All") elif result.upToPatch: patchSeqApply.applyPatchSequenceByInstallName(result.upToPatch) else: patchSeqApply.applyPatchSequenceByNumber(result.numOfPatch)
def createTestClient(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='Default KIDS Installer', parents=[testClientParser]) result = parser.parse_args() print(result) testClient = VistATestClientFactory.createVistATestClientWithArgs(result) return testClient
def createTestClient(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Patch Info Query', parents=[testClientParser]) result = parser.parse_args() print(result) testClient = VistATestClientFactory.createVistATestClientWithArgs(result) return testClient
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='Default KIDS Installer', parents=[testClientParser]) parser.add_argument('kidsFile', help='path to KIDS Build file') parser.add_argument('-l', '--logFile', default=None, help='path to logFile') parser.add_argument( '-r', '--reinstall', default=False, action='store_true', help='whether re-install the KIDS even it is already installed') parser.add_argument( '-t', '--tglobalprint', default=None, help='folder to hold a printout of Transport global information') parser.add_argument('-g', '--globalFiles', default=None, nargs='*', help='list of global files that need to import') parser.add_argument('-d', '--duz', default=DEFAULT_INSTALL_DUZ, type=int, help='installer\'s VistA instance\'s DUZ') result = parser.parse_args() print(result) testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient initConsoleLogging() with testClient: kidsFile = os.path.abspath(result.kidsFile) from KIDSBuildParser import KIDSBuildParser kidsParser = KIDSBuildParser(None) kidsParser.unregisterSectionHandler(KIDSBuildParser.ROUTINE_SECTION) kidsParser.parseKIDSBuild(kidsFile) installNameList = kidsParser.installNameList installName = installNameList[0] multiBuildList = installNameList if len(installNameList) == 1: multiBuildList = None defaultKidsInstall = DefaultKIDSBuildInstaller( kidsFile, installName, logFile=result.logFile, multiBuildList=multiBuildList, duz=result.duz, globals=result.globalFiles, printTG=result.tglobalprint) defaultKidsInstall.runInstallation(testClient, result.reinstall)
def test_exportAllClassesIndividual(): from VistATestClient import createTestClientArgParser from VistATestClient import VistATestClientFactory testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='Intersystem Cache Classes Exporter', parents=[testClientParser]) parser.add_argument('dstDir', help='Output directory to store all exported classes') result = parser.parse_args() testClient = VistATestClientFactory.createVistATestClientWithArgs(result) with testClient: exportAllClassesIndividual(testClient, result.dstDir)
def test_importDir(): from VistATestClient import createTestClientArgParser from VistATestClient import VistATestClientFactory testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='Intersystem Cache Classes Importer', parents=[testClientParser]) parser.add_argument('srcDir', help='source directory that stores all exported classes') result = parser.parse_args() testClient = VistATestClientFactory.createVistATestClientWithArgs(result) with testClient: importDir(testClient, result.srcDir)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser( description='FOIA Patch Sequence Analyzer', parents=[testClientParser]) parser.add_argument( '-f', '--foiaBranch', required=True, help='input the branch name from which the global files are downloaded' ) parser.add_argument( '-r', '--foiaRemote', required=False, default="https://raw.githubusercontent.com/OSEHRA-Sandbox/VistA-M/", help= 'input the VistA-M repository from which the global files are downloaded, must be a link to the raw data.\ Default remote is: https://raw.githubusercontent.com/OSEHRA-Sandbox/VistA-M/ ' ) parser.add_argument( '-t', '--tmpDir', required=True, help= 'input the filepath to a directory to download the necessary global files' ) parser.add_argument( '-g', '--gtmDir', required=False, help='input the filepath to a directory where GT.M stores its routines' ) parser.add_argument('-i', '--install', required=False, action="store_true", help='Attempt to install global files with ^ZGI?') parser.add_argument('-l', '--log', required=False, help='File to which I would log VistA communication') result = parser.parse_args() """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient initConsoleLogging() if result.log: testClient.setLogFile(result.log) with testClient as vistaClient: update = updateMFSGlobals() update.updateMFSGlobalFiles(vistaClient, result.foiaBranch, result.foiaRemote, result.tmpDir, result.gtmDir, result.install)
def dispatch(self): # expectConn = VistATestClientFactory.createVistATestClient(self._system, namespace=self._namespace) # if not expectConn: # return # FileManGlobalAttributes.listFileManFileAttributes(expectConn, self._fileManFile, 3, # os.path.join(self._logDir, self._fileManFile + ".custom"), # os.path.join(self._logDir, self._fileManFile + ".customlog")) expectConn = VistATestClientFactory.createVistATestClient(self._system, namespace=self._namespace) if not expectConn: return FileManGlobalAttributes.listFileManFileAttributes(expectConn, self._fileManFile, 1, os.path.join(self._logDir, self._fileManFile + ".schema"), os.path.join(self._logDir, self._fileManFile + ".log"))
def test_exportAllClassesIndividual(): from VistATestClient import createTestClientArgParser from VistATestClient import VistATestClientFactory testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser( description='Intersystem Cache Classes Exporter', parents=[testClientParser]) parser.add_argument('dstDir', help='Output directory to store all exported classes') result = parser.parse_args() testClient = VistATestClientFactory.createVistATestClientWithArgs(result) with testClient: exportAllClassesIndividual(testClient, result.dstDir)
def test_importDir(): from VistATestClient import createTestClientArgParser from VistATestClient import VistATestClientFactory testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser( description='Intersystem Cache Classes Importer', parents=[testClientParser]) parser.add_argument( 'srcDir', help='source directory that stores all exported classes') result = parser.parse_args() testClient = VistATestClientFactory.createVistATestClientWithArgs(result) with testClient: importDir(testClient, result.srcDir)
def _createTestClient(self): testClientConfig = self._config['VistA_Connection'] system = testClientConfig['system'] namespace = testClientConfig.get('namespace', DEFAULT_NAMESPACE) username = testClientConfig.get('username', None) password = testClientConfig.get('password', None) prompt = testClientConfig.get('prompt', None) return VistATestClientFactory.createVistATestClient(system, prompt=prompt, namespace=namespace, instance=self._instance, username=username, password=password)
def test1(): result = getInputArgumentResult() outputDir = result.outputDir assert os.path.exists(outputDir) initConsoleLogging() """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: vistADataExtractor = VistADataExtractor(result.vistARepo, outputDir, result.logDir, result.routineOutDir) vistADataExtractor.__exportAllCacheClasses__(testClient)
def main(): # Import Argparse and add Scripts/ directory to sys.path # by finding directory of current script and going up two levels import argparse curDir = os.path.dirname(os.path.abspath(__file__)) scriptDir = os.path.normpath(os.path.join(curDir, "../../")) if scriptDir not in sys.path: sys.path.append(scriptDir) # OSEHRA Imports from RPCBrokerCheck import CheckRPCListener from VistATestClient import createTestClientArgParser, VistATestClientFactory # Arg Parser to get address and port of RPC Listener along with a log file # Inherits the connection arguments of the testClientParser testClientParser = createTestClientArgParser() ssepTestParser = argparse.ArgumentParser( description='Test the M2M broker via XML files', parents=[testClientParser]) ssepTestParser.add_argument( "-ha", required=True, dest='host', help='Address of the host where RPC Broker is listening') ssepTestParser.add_argument( "-hp", required=True, dest='port', help='Port of the host machine where RPC Broker is listening') ssepTestParser.add_argument("-l", required=True, dest='log_file', help='Path to a file to log the output.') # A global variable so that each test is able to use the port and address of the host global results results = ssepTestParser.parse_args() testClient = VistATestClientFactory.createVistATestClientWithArgs(results) assert testClient with testClient: # If checkresult == 0, RPC listener is set up correctly and tests should be run # else, don't bother running the tests testClient.setLogFile(results.log_file) checkresult = CheckRPCListener(testClient.getConnection(), results.host, results.port) if checkresult == 0: suite = unittest.TestLoader().loadTestsFromTestCase(TestM2MBroker) unittest.TextTestRunner(verbosity=2).run(suite) else: print "FAILED: The RPC listener is not set up as needed."
def _createTestClient(self): testClientConfig = self._config['VistA_Connection'] system = testClientConfig['system'] namespace = testClientConfig.get('namespace', DEFAULT_NAMESPACE) username = testClientConfig.get('username', None) password = testClientConfig.get('password', None) prompt = testClientConfig.get('prompt', None) return VistATestClientFactory.createVistATestClient( system, prompt=prompt, namespace=namespace, instance=self._instance, username=username, password=password)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Routine Export', parents=[testClientParser]) parser.add_argument( '-o', '--outputFile', help='Output File Name to store routine export information') parser.add_argument('-a', '--allRoutines', action="store_true", default=False, help='export all routines') parser.add_argument('-r', '--routines', nargs='*', help='only specified routine names') parser.add_argument('-e', '--exclude', nargs='*', default=None, help='exclude specified routine names') parser.add_argument( '-x', '--exception', nargs='*', default=None, help='except specified routine names from the excluded routines') result = parser.parse_args() print(result) outputFilename = result.outputFile outputDir = os.path.dirname(outputFilename) assert os.path.exists(outputDir) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile(DEFAULT_OUTPUT_LOG_FILE_NAME) print "Log File is %s" % logFilename vistAClient.setLogFile(logFilename) isAllRoutines = result.allRoutines vistARoutineExport = VistARoutineExport() if isAllRoutines: vistARoutineExport.exportAllRoutines(vistAClient, outputFilename, result.exclude, result.exception) else: vistARoutineExport.exportRoutines(vistAClient, outputFilename, result.routines, result.exclude, result.exception)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Initialize FileMan Utilities', parents=[testClientParser]) parser.add_argument('roFile', help="routine import file in ro format") result = parser.parse_args(); print (result) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile() print "Log File is %s" % logFilename initConsoleLogging() vistAClient.setLogFile(logFilename) installFileMan22_2(vistAClient, result.roFile)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description="Default KIDS Installer", parents=[testClientParser]) parser.add_argument("kidsFile", help="path to KIDS Build file") parser.add_argument("-l", "--logFile", default=None, help="path to logFile") parser.add_argument( "-r", "--reinstall", default=False, action="store_true", help="whether re-install the KIDS even it is already installed", ) parser.add_argument( "-t", "--tglobalprint", default=None, help="folder to hold a printout of Transport global information" ) parser.add_argument("-g", "--globalFiles", default=None, nargs="*", help="list of global files that need to import") parser.add_argument("-d", "--duz", default=DEFAULT_INSTALL_DUZ, type=int, help="installer's VistA instance's DUZ") result = parser.parse_args() print(result) testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient initConsoleLogging() with testClient: kidsFile = os.path.abspath(result.kidsFile) from KIDSBuildParser import KIDSBuildParser kidsParser = KIDSBuildParser(None) kidsParser.unregisterSectionHandler(KIDSBuildParser.ROUTINE_SECTION) kidsParser.parseKIDSBuild(kidsFile) installNameList = kidsParser.installNameList installName = installNameList[0] multiBuildList = installNameList if len(installNameList) == 1: multiBuildList = None defaultKidsInstall = DefaultKIDSBuildInstaller( kidsFile, installName, logFile=result.logFile, multiBuildList=multiBuildList, duz=result.duz, globals=result.globalFiles, printTG=result.tglobalprint, ) defaultKidsInstall.runInstallation(testClient, result.reinstall)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description="FOIA Patch Sequence Analyzer", parents=[testClientParser]) parser.add_argument( "-p", "--patchFileDir", required=True, help="input file path to the folder that contains all the FOIA patches" ) parser.add_argument("-l", "--logDir", required=True, help="Output dirctory to store all log file information") parser.add_argument( "-i", "--install", default=False, action="store_true", help="whether to install KIDS Patch or not" ) group = parser.add_mutually_exclusive_group() group.add_argument( "-n", "--numOfPatch", default=1, help="input All for all patches, " "otherwise just enter number, default is 1" ) group.add_argument("-u", "--upToPatch", help="install patches up to specified install name") group.add_argument( "-o", "--onlyPatch", help="install specified patch and required patches only" ", this option will ignore the CSV dependencies", ) result = parser.parse_args() print(result) inputPatchDir = result.patchFileDir assert os.path.exists(inputPatchDir) outputDir = result.logDir assert os.path.exists(outputDir) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: kidsPatchApply = KIDSPatchSequenceApply(vistAClient, outputDir) if result.upToPatch: kidsPatchApply.generateKIDSPatchSequence(inputPatchDir, result.upToPatch, True) else: kidsPatchApply.generateKIDSPatchSequence(inputPatchDir, result.onlyPatch) if result.install: if result.onlyPatch: kidsPatchApply.applyKIDSPatchSequenceByNumber("All") elif result.upToPatch: kidsPatchApply.applyKIDSPatchSequenceByInstallName(result.upToPatch) else: kidsPatchApply.applyKIDSPatchSequenceByNumber(result.numOfPatch)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Global Export', parents=[testClientParser]) parser.add_argument('-o', '--outputDir', required=True, help='output Dir to store global export file in zwr format') result = parser.parse_args(); print (result) outputDir = result.outputDir assert os.path.exists(outputDir) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile() print "Log File is %s" % logFilename vistAClient.setLogFile(logFilename) vistAGlobalExport = VistAGlobalExport() vistAGlobalExport.exportAllGlobals(vistAClient, outputDir)
def testMain(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Global Import Tool', parents=[testClientParser]) parser.add_argument('-i', '--inputFile', required=True, help='input global file path to be imported to VistA') result = parser.parse_args(); print (result) inputFile = result.inputFile assert os.path.exists(inputFile) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile() print "Log File is %s" % logFilename vistAClient.setLogFile(logFilename) vistAGlobalImport = VistAGlobalImport() vistAGlobalImport.importGlobal(vistAClient, inputFile)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description="VistA M Component Extractor", parents=[testClientParser]) parser.add_argument("-o", "--outputDir", required=True, help="output Dir to store global/routine export files") parser.add_argument("-r", "--vistARepo", required=True, help="path to the top directory of VistA-M repository") parser.add_argument("-l", "--logDir", required=True, help="path to the top directory to store the log files") parser.add_argument( "-ro", "--routineOutDir", default=None, help="path to the directory where GT. M stores routines" ) result = parser.parse_args() print(result) outputDir = result.outputDir assert os.path.exists(outputDir) initConsoleLogging() """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: vistADataExtractor = VistADataExtractor(result.vistARepo, outputDir, result.logDir, result.routineOutDir) vistADataExtractor.extractData(testClient)
def main(): # Import Argparse and add Scripts/ directory to sys.path # by finding directory of current script and going up two levels import argparse curDir = os.path.dirname(os.path.abspath(__file__)) scriptDir = os.path.normpath(os.path.join(curDir, "../../")) if scriptDir not in sys.path: sys.path.append(scriptDir) # OSEHRA Imports from RPCBrokerCheck import CheckRPCListener from VistATestClient import createTestClientArgParser,VistATestClientFactory # Arg Parser to get address and port of RPC Listener along with a log file # Inherits the connection arguments of the testClientParser testClientParser = createTestClientArgParser() ssepTestParser= argparse.ArgumentParser(description='Test the M2M broker via XML files', parents=[testClientParser]) ssepTestParser.add_argument("-ha",required=True,dest='host', help='Address of the host where RPC Broker is listening') ssepTestParser.add_argument("-hp",required=True,dest='port', help='Port of the host machine where RPC Broker is listening') ssepTestParser.add_argument("-l",required=True,dest='log_file', help='Path to a file to log the output.') # A global variable so that each test is able to use the port and address of the host global results results = ssepTestParser.parse_args() testClient = VistATestClientFactory.createVistATestClientWithArgs(results) assert testClient with testClient: # If checkresult == 0, RPC listener is set up correctly and tests should be run # else, don't bother running the tests testClient.setLogFile(results.log_file) checkresult = CheckRPCListener(testClient.getConnection(),results.host,results.port) if checkresult == 0: suite = unittest.TestLoader().loadTestsFromTestCase(TestM2MBroker) unittest.TextTestRunner(verbosity=2).run(suite) else: print "FAILED: The RPC listener is not set up as needed."
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Global Export', parents=[testClientParser]) parser.add_argument( '-o', '--outputDir', required=True, help='output Dir to store global export file in zwr format') result = parser.parse_args() print(result) outputDir = result.outputDir assert os.path.exists(outputDir) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile(DEFAULT_OUTPUT_LOG_FILE_NAME) print "Log File is %s" % logFilename vistAClient.setLogFile(logFilename) vistAGlobalExport = VistAGlobalExport() vistAGlobalExport.exportAllGlobals(vistAClient, outputDir)
def testMain(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Global Import Tool', parents=[testClientParser]) parser.add_argument('inputGlobalFile', help='input global file path to be imported to VistA') parser.add_argument('-t', '--timeout', default=DEFAULT_GLOBAL_IMPORT_TIMEOUT, type=int, help=('global import time out in second, default is %s' % DEFAULT_GLOBAL_IMPORT_TIMEOUT) ) result = parser.parse_args(); print (result) inputFile = result.inputGlobalFile assert os.path.exists(inputFile) """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile() print "Log File is %s" % logFilename vistAClient.setLogFile(logFilename) vistAGlobalImport = VistAGlobalImport() vistAGlobalImport.importGlobal(vistAClient, inputFile, timeout=result.timeout)
def main(): import logging initConsoleLogging(logging.INFO) testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Taskman Utilities', parents=[testClientParser]) parser.add_argument('-a', '--action', required=True, choices=['Start', 'Stop', 'Shutdown'], help='Start:Start Taskman, Stop:Stop Taskman, Shutdown:Shutdown all tasks') result = parser.parse_args(); print result """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile(DEFAULT_OUTPUT_LOG_FILE_NAME) print "Log File is %s" % logFilename vistAClient.setLogFile(logFilename) taskmanUtil = VistATaskmanUtil() actionMap = {"Start": taskmanUtil.startTaskman, "Stop": taskmanUtil.stopTaskman, "Shutdown": taskmanUtil.shutdownAllTasks} actionMap[result.action](vistAClient)
def main(): testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='VistA Routine Import', parents=[testClientParser]) parser.add_argument('routineImportFile', help='path to Routine Import File in .ro format') parser.add_argument('-o', '--routineOutputDir', default=None, help='path to Routine output Dir, GTM only') result = parser.parse_args(); print (result) routineImportFile = result.routineImportFile assert os.path.exists(routineImportFile) routineOutputDir = result.routineOutputDir """ create the VistATestClient""" testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient as vistAClient: logFilename = getTempLogFile(DEFAULT_OUTPUT_LOG_FILE_NAME) print "Log File is %s" % logFilename vistAClient.setLogFile(logFilename) vistARoutineImport = VistARoutineImport() vistARoutineImport.importRoutines(vistAClient, routineImportFile, routineOutputDir)
def testMountDisMountLocalDb(): from VistATestClient import createTestClientArgParser from VistATestClient import VistATestClientFactory testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='InterSystem Cache Mount Dismount Test', parents=[testClientParser]) parser.add_argument('-p', '--dirPath', required=True, help='Enter directory path for the local database') parser.add_argument('-a', '--action', choices=['M','D'], required=True, type=str, help='M: mount the database, D: dismount the database. ' 'Make sure InterSystem ^DATABASE routine is accessable via' ' specified namespace.') result = parser.parse_args(); print result testClient = VistATestClientFactory.createVistATestClientWithArgs(result) with testClient: if result.action == 'D': logging.info('Dismount LocalDB: %s' % result.dirPath) dismountLocalDatabase(result.dirPath, testClient) else: logging.info('mount LocalDB: %s' % result.dirPath) mountLocalDatabase(result.dirPath, testClient)
parser.add_argument('-kb', required=True, dest='KIDSbuild', help='Path to the .KIDS file') parser.add_argument('-o', required=True, dest='outputDir', help='Path to folder to store output files') #parser.add_argument('-find', required=False, dest='Ffile', # help='Filepath to the Output file of the RFind function.') #parser.add_argument('-check', required=False, dest='Cfile', # help='Filepath to the Output file of the RCheck function.') result = parser.parse_args() # Create a test client and run the KIDSBuildParser on the supplied KIDS build testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient: KIDSParser = KIDSBuildParser(result.outputDir) KIDSParser.parseKIDSBuild(result.KIDSbuild) KIDSParser.printResult() for root, dirnames, filenames in os.walk(result.outputDir): for filename in fnmatch.filter(filenames, '*.m'): name, ext = filename.split('.') routineset.append(name) print "Writing out intial XINDEX information: Start" FullXINDEX(testClient, result.outputDir, routineset) print "Writing out intial XINDEX information: Done" resultsfolder = os.path.join(result.outputDir, "RCheck_RFind") try: os.mkdir(resultsfolder)
def createTestClient(self): from __main__ import args return VistATestClientFactory.createVistATestClientWithArgs(args)
testClientParser = createTestClientArgParser() parser = argparse.ArgumentParser(description='Processor for OTJ Evidence with a .KID submission', parents=[testClientParser]) parser.add_argument('-kb', required=True, dest='KIDSbuild', help='Path to the .KIDS file') parser.add_argument('-o', required=True, dest='outputDir', help='Path to folder to store output files') #parser.add_argument('-find', required=False, dest='Ffile', # help='Filepath to the Output file of the RFind function.') #parser.add_argument('-check', required=False, dest='Cfile', # help='Filepath to the Output file of the RCheck function.') result = parser.parse_args() # Create a test client and run the KIDSBuildParser on the supplied KIDS build testClient = VistATestClientFactory.createVistATestClientWithArgs(result) assert testClient with testClient: KIDSParser = KIDSBuildParser(result.outputDir) KIDSParser.parseKIDSBuild(result.KIDSbuild) KIDSParser.printResult() for root,dirnames,filenames in os.walk(result.outputDir): for filename in fnmatch.filter(filenames,'*.m'): name,ext = filename.split('.') routineset.append(name) print "Writing out intial XINDEX information: Start" FullXINDEX(testClient,result.outputDir,routineset) print "Writing out intial XINDEX information: Done" resultsfolder = os.path.join(result.outputDir,"RCheck_RFind") try: os.mkdir(resultsfolder)