def generate( sdk_root: str, service: str, spec_root: str, readme: str, autorest: str, use: str, output_folder: str, module: str, namespace: str, tag: str = None, version: str = None, autorest_options: str = '', **kwargs, ) -> bool: output_dir = os.path.join( sdk_root, 'sdk/{0}'.format(service), module, ) shutil.rmtree(os.path.join(output_dir, 'src/main'), ignore_errors=True) if os.path.exists(os.path.join(output_dir, 'src/samples/README.md')): # samples contains hand-written code shutil.rmtree(os.path.join(output_dir, 'src/samples/java', namespace.replace('.', '/'), 'generated'), ignore_errors=True) else: shutil.rmtree(os.path.join(output_dir, 'src/samples'), ignore_errors=True) if re.match(r'https?://', spec_root): readme = urllib.parse.urljoin(spec_root, readme) else: readme = os.path.join(spec_root, readme) tag_option = '--tag={0}'.format(tag) if tag else '' version_option = '--package-version={0}'.format(version) if version else '' command = 'autorest --version={0} --use={1} --java --java.java-sdks-folder={2} --java.output-folder={3} ' \ '--java.namespace={4} {5}'\ .format( autorest, use, os.path.abspath(sdk_root), os.path.abspath(output_dir), namespace, ' '.join((tag_option, version_option, FLUENTLITE_ARGUMENTS, autorest_options, readme)), ) logging.info(command) if os.system(command) != 0: logging.error('[GENERATE] Autorest fail') return False group = GROUP_ID update_service_ci_and_pom(sdk_root, service, group, module) update_root_pom(sdk_root, service) update_version(sdk_root, output_folder) return True
def _exec(self, args, dargs): self.job.logging.tee_redirect_debug_dir(self.debugdir, log_name=self.tagged_testname) try: if self.network_destabilizing: self.job.disable_warnings("NETWORK") # write out the test attributes into a keyval dargs = dargs.copy() run_cleanup = dargs.pop('run_cleanup', self.job.run_test_cleanup) keyvals = dargs.pop('test_attributes', {}).copy() keyvals['version'] = self.version for i, arg in enumerate(args): keyvals['param-%d' % i] = repr(arg) for name, arg in dargs.iteritems(): keyvals['param-%s' % name] = repr(arg) self.write_test_keyval(keyvals) _validate_args(args, dargs, self.initialize, self.setup, self.execute, self.cleanup) try: # Make resultsdir and tmpdir accessible to everyone. We may # output data to these directories as others, e.g., chronos. self._make_writable_to_others(self.tmpdir) self._make_writable_to_others(self.resultsdir) # Initialize: _cherry_pick_call(self.initialize, *args, **dargs) lockfile = open(os.path.join(self.job.tmpdir, '.testlock'), 'w') try: fcntl.flock(lockfile, fcntl.LOCK_EX) # Setup: (compile and install the test, if needed) p_args, p_dargs = _cherry_pick_args(self.setup, args, dargs) utils.update_version(self.srcdir, self.preserve_srcdir, self.version, self.setup, *p_args, **p_dargs) finally: fcntl.flock(lockfile, fcntl.LOCK_UN) lockfile.close() # Execute: os.chdir(self.outputdir) # call self.warmup cherry picking the arguments it accepts and # translate exceptions if needed _call_test_function(_cherry_pick_call, self.warmup, *args, **dargs) if hasattr(self, 'run_once'): p_args, p_dargs = _cherry_pick_args(self.run_once, args, dargs) # pull in any non-* and non-** args from self.execute for param in _get_nonstar_args(self.execute): if param in dargs: p_dargs[param] = dargs[param] else: p_args, p_dargs = _cherry_pick_args(self.execute, args, dargs) _call_test_function(self.execute, *p_args, **p_dargs) except Exception: # Save the exception while we run our cleanup() before # reraising it, but log it to so actual time of error is known. exc_info = sys.exc_info() logging.warning('Autotest caught exception when running test:', exc_info=True) try: try: if run_cleanup: _cherry_pick_call(self.cleanup, *args, **dargs) except Exception: logging.error('Ignoring exception during cleanup() ' 'phase:') traceback.print_exc() logging.error('Now raising the earlier %s error', exc_info[0]) self.crash_handler_report() finally: self.job.logging.restore() try: raise exc_info[0], exc_info[1], exc_info[2] finally: # http://docs.python.org/library/sys.html#sys.exc_info # Be nice and prevent a circular reference. del exc_info else: try: if run_cleanup: _cherry_pick_call(self.cleanup, *args, **dargs) self.crash_handler_report() finally: self.job.logging.restore() except error.AutotestError: if self.network_destabilizing: self.job.enable_warnings("NETWORK") # Pass already-categorized errors on up. raise except Exception, e: if self.network_destabilizing: self.job.enable_warnings("NETWORK") # Anything else is an ERROR in our own code, not execute(). raise error.UnhandledTestError(e)
import utils current_version = int(utils.get_maldb_ver()) with open("./virusDB/output{}0.txt".format(current_version + 1), "rb") as fin: for i, line in enumerate(fin): print(line) try: utils.get_virus_infos(line) except Exception as ex: print(ex) print('error line') utils.update_version(current_version) fin.close()