def _check_defined_tests(self, tester, tests): if self.options.blacklisted_tests or self.options.wanted_tests: return tests_names = [test.classname for test in tests] for testsuite in self.options.testsuites: if not self._other_testsuite_for_tester(testsuite, tester): try: testlist_file = open(os.path.splitext(testsuite.__file__)[0] + ".testslist", 'rw') know_tests = testlist_file.read().split("\n") testlist_file.close() testlist_file = open(os.path.splitext(testsuite.__file__)[0] + ".testslist", 'w') except IOError: return for test in know_tests: if test and test not in tests_names: printc("Test %s Not in testsuite %s anymore" % (test, testsuite.__file__), Colors.FAIL) for test in tests_names: testlist_file.write("%s\n" % test) if test and test not in know_tests: printc("Test %s is NEW in testsuite %s" % (test, testsuite.__file__), Colors.OKGREEN) testlist_file.close() return
def set_default_blacklist(self, default_blacklist): msg = "\nCurrently 'hardcoded' %s blacklisted tests:\n\n" % self.name for name, bug in default_blacklist: self._add_blacklist(name) msg += " + %s \n --> bug: %s\n" % (name, bug) printc(msg, Colors.FAIL, True)
def stash(arg=None, debug=conf.Debug): ''' stash a specific task or display the currently stashed tasks list by default ''' if arg in [None, 'list']: content = ['tasks stashed:'] tasks = mt.find({'status': 'stashed'}) for item in tasks: content.append('#' + item['task_id'] + ' - ' + item['title']) if content: return content else: utils.printc('we are clean.') # accepts bytes here to deal with task instances elif type(arg) == type(b''): print('really need to accept bytes obj?') else: # prepare task attrs to set t = getTask(arg) t.focus = False t.status = 'stashed' t.paused = int(time.time()) t.context = input('persistize your mind as context:\n') t.acrossing = None # update in db and register in parent t.sync() if debug: print('task #' + t._id + ' stashed.')
def cleanup(self): """ Cleanup the options looking after user options have been parsed """ # Get absolute path for main_dir and base everything on that self.main_dir = os.path.abspath(self.main_dir) # default for output_dir is MAINDIR if not self.output_dir: self.output_dir = self.main_dir else: self.output_dir = os.path.abspath(self.output_dir) # other output directories if self.logsdir is None: self.logsdir = os.path.join(self.output_dir, "logs") if self.xunit_file is None: self.xunit_file = os.path.join(self.logsdir, "xunit.xml") if self.dest is None: self.dest = os.path.join(self.output_dir, "rendered") if not os.path.exists(self.dest): os.makedirs(self.dest) if urlparse.urlparse(self.dest).scheme == "": self.dest = path2url(self.dest) if self.no_color: utils.desactivate_colors() if self.clone_dir is None: self.clone_dir = os.path.join(self.main_dir, QA_ASSETS) if not isinstance(self.paths, list): self.paths = [self.paths] if self.generate_info_full is True: self.generate_info = True if self.sync_all is True: self.sync = True if self.update_assets_command == DEFAULT_SYNC_ASSET_COMMAND: self.update_assets_command = DEFAULT_SYNC_ALL_ASSET_COMMAND if not self.sync and not os.path.exists(self.clone_dir) and \ self.clone_dir == os.path.join(self.clone_dir, MEDIAS_FOLDER): printc("Media path (%s) does not exists. Forgot to run --sync ?" % self.clone_dir, Colors.FAIL, True) return False if (self.main_dir != DEFAULT_MAIN_DIR or self.clone_dir != QA_ASSETS) and \ self.testsuites_dir == DEFAULT_TESTSUITES_DIR: self.testsuites_dir = os.path.join(self.main_dir, self.clone_dir, "testsuites") return True
def _load_config(self, options): printc("Loading config files is DEPRECATED" " you should use the new testsuite format now",) for tester in self.testers: tester.options = options globals()[tester.name] = tester globals()["options"] = options c__file__ = __file__ globals()["__file__"] = self.options.config execfile(self.options.config, globals()) globals()["__file__"] = c__file__
def focus(arg=None): '''use focus() to switch active between tasks. display a prettfied task list by default like ' <1> TASK ID - TITLE (context optional)' can only switch to stashed tasks: can be used to restore auto-stashed task from last block display context when restore ''' if arg in [None]: ''' default action ''' if stash(): content = [] for item in stash(): content.append(item) utils.printc(content) # choose from list above choice = input('\033[0;35m' + 'choose a task to focus[1~' + str(len(content) - 1) + ']:') print('\033[0m') if choice: if checkFocus(): cf = checkFocus() # unfocus current focusing one cfId = cf['task_id'] setFocus(cfId, False) # unregister in its parent old_parent = cf['parent'] setFocus(old_parent, False) # focus the destined one dest = content[int(choice)].split(' ')[0][1:] setFocus(dest, True) # register in its parent new_parent = getParent(dest) setFocus(new_parent, True) else: pass else: content = ["no stashed task. ", "try add('a task')"] utils.printc(content)
def update_assets(options): try: launch_command("cd %s && %s" % (options.clone_dir, options.update_assets_command), fails=True) except subprocess.CalledProcessError as e: if "annex" in options.update_assets_command: m = "\n\nMAKE SURE YOU HAVE git-annex INSTALLED!" else: m = "" printc("Could not update assets repository\n\nError: %s%s" % (e, m), Colors.FAIL, True) return False return True
def run(self): self.command = "%s " % (self.application) self._starting_time = time.time() self.build_arguments() proc_env = self.get_subproc_env() message = "Launching: %s%s\n" \ " Command: '%s'\n" \ " Logs:\n" \ " - %s" % (Colors.ENDC, self.classname, self.command, self.logfile) for log in self.extra_logfiles: message += "\n - %s" % log printc(message, Colors.OKBLUE) try: self.process = subprocess.Popen("exec " + self.command, stderr=self.reporter.out, stdout=self.reporter.out, shell=True, env=proc_env) self.wait_process() except KeyboardInterrupt: self.process.send_signal(signal.SIGINT) raise try: self.process.send_signal(signal.SIGINT) except OSError: pass self.time_taken = time.time() - self._starting_time self.reporter.out.seek(0) self.reporter.out.write("=================\n" "Test name: %s\n" "Command: '%s'\n" "=================\n\n" % (self.classname, self.command)) printc("Result: %s%s\n" % (self.result, " (" + self.message + ")" if self.message else ""), color=utils.get_color_for_result(self.result)) return self.result
def download_assets(options): try: launch_command("%s %s %s" % (options.get_assets_command, options.remote_assets_url, options.clone_dir), fails=True) except subprocess.CalledProcessError as e: if "git" in options.get_assets_command: m = "\n\nMAKE SURE YOU HAVE git INSTALLED!" else: m = "" printc("Could not download assets\n\nError: %s%s" % (e, m), Colors.FAIL, True) return False return True
def _setup_testsuites(self): for testsuite in self.options.testsuites: loaded = False wanted_test_manager = None if hasattr(testsuite, "TEST_MANAGER"): wanted_test_manager = testsuite.TEST_MANAGER if not isinstance(wanted_test_manager, list): wanted_test_manager = [wanted_test_manager] for tester in self.testers: if wanted_test_manager is not None and \ tester.name not in wanted_test_manager: continue if testsuite.setup_tests(tester, self.options): loaded = True if not loaded: printc("Could not load testsuite: %s" " maybe because of missing TestManager" % (testsuite), Colors.FAIL)
def new_from_uri(uri, verbose=False, full=False): media_path = utils.url2path(uri) descriptor_path = "%s.%s" % ( media_path, GstValidateMediaDescriptor.MEDIA_INFO_EXT) args = GstValidateMediaDescriptor.DISCOVERER_COMMAND.split(" ") args.append(uri) args.extend(["--output-file", descriptor_path]) if full: args.extend(["--full"]) if verbose: printc("Generating media info for %s\n" " Command: '%s'" % (media_path, ' '.join(args)), Colors.OKBLUE) try: subprocess.check_output(args, stderr=open(os.devnull)) except subprocess.CalledProcessError as e: if verbose: printc("Result: Failed", Colors.FAIL) else: loggable.warning("GstValidateMediaDescriptor", "Exception: %s" % e) return None if verbose: printc("Result: Passed", Colors.OKGREEN) return GstValidateMediaDescriptor(descriptor_path)
def build_vocabulary(self, dataset, filepath): if not os.path.exists(filepath): printc("start build vocabulary") frequencies = {} idx = 4 for _, sentence_list in tqdm(dataset, total=len(dataset)): for sentence in sentence_list: for word in self.tokenizer_eng(sentence): if word not in frequencies.keys(): frequencies[word] = 1 else: frequencies[word] += 1 if frequencies[word] == self.freq_threadshold: self.stoi[word] = idx self.itos[idx] = word idx += 1 self.save_vocab(filepath) else: self.load_vocab(filepath)
def _load_testsuites(self): testsuites = [] for testsuite in self.options.testsuites: if not os.path.isabs(testsuite): testsuite = os.path.join(self.options.testsuites_dir, testsuite + ".py") try: sys.path.insert(0, os.path.dirname(testsuite)) module = __import__(os.path.basename(testsuite).replace(".py", "")) except Exception as e: printc("Could not load testsuite: %s, reason: %s" % (testsuite, e), Colors.FAIL) continue finally: sys.path.remove(os.path.dirname(testsuite)) testsuites.append(module) if not hasattr(module, "TEST_MANAGER"): module.TEST_MANAGER = [tester.name for tester in self.testers] elif not isinstance(module.TEST_MANAGER, list): module.TEST_MANAGER = [module.TEST_MANAGER] self.options.testsuites = testsuites
def update_assets(options): try: if options.remote_assets_url == DEFAULT_GST_QA_ASSETS_REPO: if re.findall("origin.*%s" % OLD_DEFAULT_GST_QA_ASSETS_REPO, subprocess.check_output("cd %s && git remote -v" % options.clone_dir, shell=True)): launch_command("cd %s && git remote set-url origin %s" % (options.clone_dir, DEFAULT_GST_QA_ASSETS_REPO)) launch_command("cd %s && %s" % (options.clone_dir, options.update_assets_command), fails=True) except subprocess.CalledProcessError as e: if "annex" in options.update_assets_command: m = "\n\nMAKE SURE YOU HAVE git-annex INSTALLED!" else: m = "" printc("Could not update assets repository\n\nError: %s%s" % (e, m), Colors.FAIL, True) return False return True
def mainMenu(clean, colors): while True: clear(clean, colors) for i,j in menu.items(): printc(f"{12 * ' '}{colors['green']}[{i}]{colors['none']}{j}") mainChoice = str(input("\n\n\n>>>")).lower() if mainChoice == 'g': passGenerate(clean, colors) elif mainChoice == 't': passCheck(clean, colors) elif mainChoice == 'e': clear(clean, colors) time.sleep(1) printc(f"{colors['green']}Thanks for using!") time.sleep(2) printc(f"Visit {colors['cyan']}www.codeblins.online{colors['green']} for more fun stuff!") time.sleep(2) printc(f"psyborg0ne, changing passwords since 1997") time.sleep(5) exit()
def cleanup(self): """ Cleanup the options looking after user options have been parsed """ # Get absolute path for main_dir and base everything on that self.main_dir = os.path.abspath(self.main_dir) # default for output_dir is MAINDIR if not self.output_dir: self.output_dir = self.main_dir else: self.output_dir = os.path.abspath(self.output_dir) if self.gdb: self.logsdir = "stdout" self.debug = True self.num_jobs = 1 try: subprocess.check_output("gdb --help", shell=True) except subprocess.CalledProcessError: printc("Want to use gdb, but not avalaible on the system", Colors.FAIL) return False # other output directories if self.logsdir in ['stdout', 'stderr']: # Allow -l stdout/stderr to work like -rl stdout/stderr self.redirect_logs = self.logsdir self.logsdir = None if self.logsdir is None: self.logsdir = os.path.join(self.output_dir, "logs") if self.xunit_file is None: self.xunit_file = os.path.join(self.logsdir, "xunit.xml") if self.dest is None: self.dest = os.path.join(self.output_dir, "rendered") if not os.path.exists(self.dest): os.makedirs(self.dest) if not os.path.exists(self.logsdir): os.makedirs(self.logsdir) if self.redirect_logs not in ['stdout', 'stderr', False]: printc("Log redirection (%s) must be either 'stdout' or 'stderr'." % self.redirect_logs, Colors.FAIL, True) return False if urlparse.urlparse(self.dest).scheme == "": self.dest = path2url(self.dest) if self.no_color: utils.desactivate_colors() if self.clone_dir is None: self.clone_dir = os.path.join(self.main_dir, QA_ASSETS) if not isinstance(self.paths, list): self.paths = [self.paths] if self.generate_info_full is True: self.generate_info = True if self.sync_all is True or self.force_sync is True: self.sync = True if not self.sync and not os.path.exists(self.clone_dir) and \ self.clone_dir == os.path.join(self.clone_dir, MEDIAS_FOLDER): printc("Media path (%s) does not exists. Forgot to run --sync ?" % self.clone_dir, Colors.FAIL, True) return False if (self.main_dir != DEFAULT_MAIN_DIR or self.clone_dir != QA_ASSETS) and \ self.testsuites_dir == DEFAULT_TESTSUITES_DIR: self.testsuites_dir = os.path.join(self.main_dir, self.clone_dir, "testsuites") if self.valgrind: try: subprocess.check_output("valgrind --help", shell=True) except subprocess.CalledProcessError: printc("Want to use valgrind, but not avalaible on the system", Colors.FAIL) return False return True
import iso8601 import utils from utils import printc from config import Config from online import OnlineApiClient, OnlineApiError from exceptions import CriticalError VERSION = "2.1.0" try: # Here's a cute birb (oiseau=birb in french) printc( """ ___ ( "> )( // ) jgs --//""-- -/------""", utils.BColors.YELLOW) printc(" " * 7 + "oiseau @{}\n".format(VERSION), utils.BColors.YELLOW + utils.BColors.BOLD) # Load config config = Config() # Always run API checks # Check online.net api token if config.is_c14: client = OnlineApiClient(config["ONLINE_API_KEY"]) logged_in = client.auth_valid() if not logged_in:
def main(libsdir): if "--help" in sys.argv: _help_message = HELP else: _help_message = "Use --help for the full help" parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter, prog='gst-validate-launcher', description=_help_message) parser.add_argument('testsuites', metavar='N', nargs='*', help="""Lets you specify a file where the testsuite to execute is defined. In the module if you want to work with a specific test manager(s) (for example, 'ges' or 'validate'), you should define the TEST_MANAGER variable in the testsuite file (it can be a list of test manager names) In this file you should implement a setup_tests function. That function takes a TestManager and the GstValidateLauncher option as parameters and return True if it succeeded loading the tests, False otherwise. You will be able to configure the TestManager with its various methods. This function will be called with each TestManager usable, for example you will be passed the 'validate' TestManager in case the GstValidateManager launcher is available. You should configure it using: * test_manager.add_scenarios: which allows you to register a list of scenario names to be run * test_manager.set_default_blacklist: Lets you set a list of tuple of the form: (@regex_defining_blacklister_test_names, @reason_for_the_blacklisting) * test_manager.add_generators: which allows you to register a list of #GstValidateTestsGenerator to be used to generate tests * test_manager.add_encoding_formats:: which allows you to register a list #MediaFormatCombination to be used for transcoding tests You can also set default values with: * test_manager.register_defaults: Sets default values for all parametters * test_manager.register_default_test_generators: Sets default values for the TestsGenerators to be used * test_manager.register_default_scenarios: Sets default values for the scenarios to be executed * test_manager.register_default_encoding_formats: Sets default values for the encoding formats to be tested Note that all testsuite should be inside python modules, so the directory should contain a __init__.py file """, default=["validate"]) parser.add_argument("-d", "--debug", dest="debug", action="store_true", help="Let user debug the process on timeout") parser.add_argument("-f", "--forever", dest="forever", action="store_true", help="Keep running tests until one fails") parser.add_argument("-F", "--fatal-error", dest="fatal_error", action="store_true", help="Stop on first fail") parser.add_argument("--fail-on-testlist-change", dest="fail_on_testlist_change", action="store_true", help="Fail the testsuite if a test has been added" " or removed without being explicitely added/removed " "from the testlist file.") parser.add_argument("-t", "--wanted-tests", dest="wanted_tests", action="append", help="Define the tests to execute, it can be a regex." " If it contains defaults_only, only default scenarios" " will be executed") parser.add_argument("-b", "--blacklisted-tests", dest="blacklisted_tests", action="append", help="Define the tests not to execute, it can be a regex.") parser.add_argument("-L", "--list-tests", dest="list_tests", action="store_true", help="List tests and exit") parser.add_argument("-m", "--mute", dest="mute", action="store_true", help="Mute playback output, which means that we use " "a fakesink") parser.add_argument("-n", "--no-color", dest="no_color", action="store_true", help="Set it to output no colored text in the terminal") parser.add_argument("-g", "--generate-media-info", dest="generate_info", action="store_true", help="Set it in order to generate the missing .media_infos files") parser.add_argument("--update-media-info", dest="update_media_info", action="store_true", help="Set it in order to update exising .media_infos files") parser.add_argument( "-G", "--generate-media-info-with-frame-detection", dest="generate_info_full", action="store_true", help="Set it in order to generate the missing .media_infos files. " "It implies --generate-media-info but enabling frame detection") parser.add_argument("-lt", "--long-test-limit", dest="long_limit", action='store', help="Defines the limit for which a test is considered as long (in seconds)." " Note that 0 will enable all tests", type=int), parser.add_argument("--dump-on-failure", dest="dump_on_failure", action="store_true", default=False, help="Dump logs to stdout when a test fails") parser.add_argument("-c", "--config", dest="config", help="This is DEPRECATED, prefer using the testsuite format" " to configure testsuites") parser.add_argument("-vg", "--valgrind", dest="valgrind", action="store_true", help="Run the tests inside Valgrind") parser.add_argument("--gdb", dest="gdb", action="store_true", help="Run the tests inside gdb (implies" " --output-dir=stdout and --jobs=1)") parser.add_argument("-nd", "--no-display", dest="no_display", action="store_true", help="Run the tests without outputting graphics" " on any display. It tries to run all graphical operation" " in a virtual framebuffer." " Note that it is currently implemented only" " for the X server thanks to Xvfb (which is requeried in that case)") dir_group = parser.add_argument_group( "Directories and files to be used by the launcher") parser.add_argument('--xunit-file', action='store', dest='xunit_file', metavar="FILE", help=("Path to xml file to store the xunit report in.")) dir_group.add_argument("-M", "--main-dir", dest="main_dir", help="Main directory where to put files. Default is %s" % DEFAULT_MAIN_DIR) dir_group.add_argument("--testsuites-dir", dest="testsuites_dir", help="Directory where to look for testsuites. Default is %s" " Note that GstValidate expect testsuite file to have .testsuite" " as an extension in this folder." % DEFAULT_TESTSUITES_DIR) dir_group.add_argument("-o", "--output-dir", dest="output_dir", help="Directory where to store logs and rendered files. Default is MAIN_DIR") dir_group.add_argument("-l", "--logs-dir", dest="logsdir", help="Directory where to store logs, default is OUTPUT_DIR/logs.") dir_group.add_argument("-R", "--render-path", dest="dest", help="Set the path to which projects should be rendered, default is OUTPUT_DIR/rendered") dir_group.add_argument("-p", "--medias-paths", dest="user_paths", action="append", help="Paths in which to look for media files") dir_group.add_argument("-a", "--clone-dir", dest="clone_dir", help="Paths where to clone the testuite to run " " default is MAIN_DIR/gst-integration-testsuites") dir_group.add_argument("-rl", "--redirect-logs", dest="redirect_logs", help="Redirect logs to 'stdout' or 'sdterr'.") dir_group.add_argument("-j", "--jobs", dest="num_jobs", help="Number of tests to execute simultaneously", type=int) http_server_group = parser.add_argument_group( "Handle the HTTP server to be created") http_server_group.add_argument( "--http-server-port", dest="http_server_port", help="Port on which to run the http server on localhost", type=int) http_server_group.add_argument( "--http-bandwith-limitation", dest="http_bandwith", help="The artificial bandwith limitation to introduce to the local server (in Bytes/sec) (default: 1 MBps)") http_server_group.add_argument( "-s", "--folder-for-http-server", dest="http_server_dir", help="Folder in which to create an http server on localhost. Default is PATHS") http_server_group.add_argument("--http-only", dest="httponly", action='store_true', help="Start the http server and quit") assets_group = parser.add_argument_group("Handle remote assets") assets_group.add_argument( "--get-assets-command", dest="get_assets_command", help="Command to get assets") assets_group.add_argument("--remote-assets-url", dest="remote_assets_url", help="Url to the remote assets (default:%s)" % DEFAULT_GST_QA_ASSETS_REPO) assets_group.add_argument("-S", "--sync", dest="sync", action="store_true", help="Synchronize asset repository") assets_group.add_argument("-fs", "--force-sync", dest="force_sync", action="store_true", help="Synchronize asset repository reseting any change that might have" " happened in the testsuite") assets_group.add_argument("--sync-all", dest="sync_all", action="store_true", help="Synchronize asset repository," " including big media files") assets_group.add_argument("--usage", action=PrintUsage, help="Print usage documentation") loggable.init("GST_VALIDATE_LAUNCHER_DEBUG", True, False) tests_launcher = _TestsLauncher(libsdir) tests_launcher.add_options(parser) if _help_message == HELP and which(LESS): tmpf = tempfile.NamedTemporaryFile() parser.print_help(file=tmpf) exit(os.system("%s %s" % (LESS, tmpf.name))) options = LauncherConfig() parser.parse_args(namespace=options) if not options.cleanup(): exit(1) if options.remote_assets_url and options.sync and not os.path.exists(options.clone_dir): if not download_assets(options): exit(1) # Ensure that the scenario manager singleton is ready to be used ScenarioManager().config = options if not tests_launcher.set_settings(options, []): exit(1) if tests_launcher.list_tests() == -1: printc("\nFailling as tests have been removed/added " " (--fail-on-testlist-change)", Colors.FAIL) exit(1) if options.list_tests: l = tests_launcher.tests for test in l: printc(test) printc("\nNumber of tests: %d" % len(l), Colors.OKGREEN) return 0 httpsrv = HTTPServer(options) if tests_launcher.needs_http_server() or options.httponly is True: httpsrv.start() vfb_server = get_virual_frame_buffer_server(options) if options.no_display: res = vfb_server.start() if res[0] is False: printc("Could not start virtual frame server: %s" % res[1], Colors.FAIL) exit(1) os.environ["DISPLAY"] = vfb_server.display_id if options.httponly is True: print("Running HTTP server only") return # There seems to be some issue with forking, dconf and some gtype # initialization that deadlocks occasionally, setting the # GSettings backend make it go away. # Also happened here: https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/tests/check/Makefile.am?id=8e2c1d1de56bddbff22170f8b17473882e0e63f9 os.environ['GSETTINGS_BACKEND'] = "memory" e = None try: tests_launcher.run_tests() except Exception as e: pass finally: tests_launcher.final_report() tests_launcher.clean_tests() httpsrv.stop() vfb_server.stop() if e is not None: raise return 0
import os,sys,Image from utils import printc if len(sys.argv)==1: printc("Drop files on me to rename...",'red') raw_input('\nPress any key to exit...') else: try: dirmode = False lst = sys.argv[1:] count = len(lst) length = len(str(count)) if count==1 and os.path.isdir(lst[0])==True: dirname = lst[0] lst = [dirname+'\\'+item for item in os.listdir(lst[0])] count = len(lst) length = len(str(count)) dirmode = True #print lst for item in lst: try: if os.path.isdir(item):raise Exception('Directories should be parsed one by one.') pos = item.rindex('.')+1 name = item[:pos] sname = item[item.rindex('\\')+1:pos] img = Image.open(item) img.save(name+'jpg',quality=80) printc(('[%' + str(length) +'d/%' + str(length) + 'd] ') % (lst.index(item)+1,count), 'green', end='') print sname+'jpg' except Exception as e: printc(('[%' + str(length) +'d/%' + str(length) + 'd] ') % (lst.index(item)+1,count), 'red', end='')
def set_http_server_dir(self, path): if self.http_server_dir is not None: printc("Server directory already set to %s" % self.http_server_dir) return self.http_server_dir = path
def cleanup(self): """ Cleanup the options looking after user options have been parsed """ # Get absolute path for main_dir and base everything on that self.main_dir = os.path.abspath(self.main_dir) # default for output_dir is MAINDIR if not self.output_dir: self.output_dir = self.main_dir else: self.output_dir = os.path.abspath(self.output_dir) if self.gdb: self.logsdir = "stdout" self.debug = True self.num_jobs = 1 try: subprocess.check_output("gdb --help", shell=True) except subprocess.CalledProcessError: printc("Want to use gdb, but not avalaible on the system", Colors.FAIL) return False # other output directories if self.logsdir in ['stdout', 'stderr']: # Allow -l stdout/stderr to work like -rl stdout/stderr self.redirect_logs = self.logsdir self.logsdir = None if self.logsdir is None: self.logsdir = os.path.join(self.output_dir, "logs") if self.xunit_file is None: self.xunit_file = os.path.join(self.logsdir, "xunit.xml") if self.dest is None: self.dest = os.path.join(self.output_dir, "rendered") if not os.path.exists(self.dest): os.makedirs(self.dest) if not os.path.exists(self.logsdir): os.makedirs(self.logsdir) if self.redirect_logs not in ['stdout', 'stderr', False]: printc( "Log redirection (%s) must be either 'stdout' or 'stderr'." % self.redirect_logs, Colors.FAIL, True) return False if urlparse.urlparse(self.dest).scheme == "": self.dest = path2url(self.dest) if self.no_color: utils.desactivate_colors() if self.clone_dir is None: self.clone_dir = os.path.join(self.main_dir, QA_ASSETS) if not isinstance(self.paths, list): self.paths = [self.paths] if self.generate_info_full is True: self.generate_info = True if self.sync_all is True or self.force_sync is True: self.sync = True if not self.sync and not os.path.exists(self.clone_dir) and \ self.clone_dir == os.path.join(self.clone_dir, MEDIAS_FOLDER): printc( "Media path (%s) does not exists. Forgot to run --sync ?" % self.clone_dir, Colors.FAIL, True) return False if (self.main_dir != DEFAULT_MAIN_DIR or self.clone_dir != QA_ASSETS) and \ self.testsuites_dir == DEFAULT_TESTSUITES_DIR: self.testsuites_dir = os.path.join(self.main_dir, self.clone_dir, "testsuites") if self.valgrind: try: subprocess.check_output("valgrind --help", shell=True) except subprocess.CalledProcessError: printc("Want to use valgrind, but not avalaible on the system", Colors.FAIL) return False return True
import os, sys, Image from utils import printc if len(sys.argv) == 1: printc("Drop files on me to rename...", 'red') raw_input('\nPress any key to exit...') else: try: lst = sys.argv[1:] count = len(lst) length = len(str(count)) #print lst for item in lst: pos = item.rindex('.') + 1 name = item[:pos] sname = item[item.rindex('\\') + 1:pos] img = Image.open(item) width, height = img.size img = img.crop((6, 28, width - 6, height - 6)) img.save(name + 'jpg', quality=80) printc(('[%' + str(length) + 'd/%' + str(length) + 'd] ') % (lst.index(item) + 1, count), 'green', end='') print sname + 'jpg' except Exception as e: printc(e.message, 'red') finally: raw_input('\nPress any key to exit...')
def final_report(self): print "\n" printc("Final Report:", title=True) for test in sorted(self.results, key=lambda test: test.result): printc(test) if test.result != Result.PASSED: print "\n" print "\n" lenstat = (len("Statistics") + 1) printc("Statistics:\n%s" % (lenstat * "-"), Colors.OKBLUE) printc("\n%sTotal time spent: %s seconds\n" % ((lenstat * " "), datetime.timedelta( seconds=(time.time() - self._start_time))), Colors.OKBLUE) printc("%sPassed: %d" % (lenstat * " ", self.stats["passed"]), Colors.OKGREEN) printc("%sFailed: %d" % (lenstat * " ", self.stats["failures"]), Colors.FAIL) printc("%s%s" % (lenstat * " ", (len("Failed: 0")) * "-"), Colors.OKBLUE) total = self.stats["failures"] + self.stats["passed"] color = Colors.WARNING if total == self.stats["passed"]: color = Colors.OKGREEN elif total == self.stats["failures"]: color = Colors.FAIL printc("%sTotal: %d" % (lenstat * " ", total), color)
def now(arg=None): ''' run this after boc, or after tf, or just any time you feel lost when no task active, gives task list so that one can get to know what to do really quick. one can pick up a task to focus, or checkout something meaningful (important infos would be sent into now() by other functions but won't disturb you instantly) and this function should stay as extremely simple ''' def nowsPlus1(instance): instance.nows += 1 setStatusInDB(instance._id, 'nows', instance.nows) return if checkFocus(): t = getTask() # utils.printc utils.printc('#' + t._id + ' - ' + t.title) # nows += 1 nowsPlus1(t) elif getBlock().status == 'active': # if we have tasks registered in current active block if getBlock().tasks: b = getBlock() tasks = [pickle.loads(item) for item in b.tasks] finished, stashed = [], [] content = ['block #' + b._id + "[active]", '\n', 'finished:'] # distinguish tasks by status for item in tasks: if item.status == 'finished': finished.append('#' + item._id + ' - ' + item.title) elif item.status == 'stashed': stashed.append('#' + item._id + ' - ' + item.title) for item in finished: content.append(item) # separator content.append('\n') content.append('stashed:') # then append stashed tasks for item in stashed: content.append(item) # finally content.append('\n') content.append("no active task right now. try 'add(a task)'") utils.printc(content) elif getTask('s'): stashed = getTask('s') content = ['stashed:'] for item in stashed: content.append(item['task_id'] + ' - ' + item['title']) utils.printc(content) else: utils.printc("pure nothing", "try add('a task')") else: content = ['not at work.', "'boc()' when you feel like begin."] utils.printc(content)
def final_report(self): print "\n" printc("Final Report:", title=True) for test in self.results: printc(test) print "\n" lenstat = (len("Statistics") + 1) printc("Statistics:\n%s" %(lenstat * "-"), Colors.OKBLUE) printc("%sPassed: %d" % (lenstat * " ", self.stats["passed"]), Colors.OKGREEN) printc("%sFailed: %d" % (lenstat * " ", self.stats["failures"]), Colors.FAIL) printc("%s%s" %(lenstat * " ", (len("Failed: 0")) * "-"), Colors.OKBLUE) total = self.stats["failures"] + self.stats["passed"] color = Colors.WARNING if total == self.stats["passed"]: color = Colors.OKGREEN elif total == self.stats["failures"]: color = Colors.FAIL printc("%sTotal: %d" % (lenstat * " ", total), color)
def main(libsdir): if "--help" in sys.argv: _help_message = HELP else: _help_message = "Use --help for the full help" parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter, prog='gst-validate-launcher', description=_help_message) parser.add_argument('testsuites', metavar='N', nargs='*', help="""Lets you specify a file where the testsuite to execute is defined. In the module if you want to work with a specific test manager(s) (for example, 'ges' or 'validate'), you should define the TEST_MANAGER variable in the testsuite file (it can be a list of test manager names) In this file you should implement a setup_tests function. That function takes a TestManager and the GstValidateLauncher option as parameters and return True if it succeeded loading the tests, False otherwise. You will be able to configure the TestManager with its various methods. This function will be called with each TestManager usable, for example you will be passed the 'validate' TestManager in case the GstValidateManager launcher is avalaible. You should configure it using: * test_manager.add_scenarios: which allows you to register a list of scenario names to be run * test_manager.set_default_blacklist: Lets you set a list of tuple of the form: (@regex_defining_blacklister_test_names, @reason_for_the_blacklisting) * test_manager.add_generators: which allows you to register a list of #GstValidateTestsGenerator to be used to generate tests * test_manager.add_encoding_formats:: which allows you to register a list #MediaFormatCombination to be used for transcoding tests You can also set default values with: * test_manager.register_defaults: Sets default values for all parametters * test_manager.register_default_test_generators: Sets default values for the TestsGenerators to be used * test_manager.register_default_scenarios: Sets default values for the scenarios to be executed * test_manager.register_default_encoding_formats: Sets default values for the encoding formats to be tested Note that all testsuite should be inside python modules, so the directory should contain a __init__.py file """, default=["validate"]) parser.add_argument("-d", "--debug", dest="debug", action="store_true", help="Let user debug the process on timeout") parser.add_argument("-f", "--forever", dest="forever", action="store_true", help="Keep running tests until one fails") parser.add_argument("-F", "--fatal-error", dest="fatal_error", action="store_true", help="Stop on first fail") parser.add_argument("-t", "--wanted-tests", dest="wanted_tests", action="append", help="Define the tests to execute, it can be a regex." " If it contains defaults_only, only default scenarios" " will be executed") parser.add_argument("-b", "--blacklisted-tests", dest="blacklisted_tests", action="append", help="Define the tests not to execute, it can be a regex.") parser.add_argument("-L", "--list-tests", dest="list_tests", action="store_true", help="List tests and exit") parser.add_argument("-m", "--mute", dest="mute", action="store_true", help="Mute playback output, which means that we use " "a fakesink") parser.add_argument("-n", "--no-color", dest="no_color", action="store_true", help="Set it to output no colored text in the terminal") parser.add_argument("-g", "--generate-media-info", dest="generate_info", action="store_true", help="Set it in order to generate the missing .media_infos files") parser.add_argument("--update-media-info", dest="update_media_info", action="store_true", help="Set it in order to update exising .media_infos files") parser.add_argument( "-G", "--generate-media-info-with-frame-detection", dest="generate_info_full", action="store_true", help="Set it in order to generate the missing .media_infos files. " "It implies --generate-media-info but enabling frame detection") parser.add_argument("-lt", "--long-test-limit", dest="long_limit", action='store', help="Defines the limit for which a test is considered as long (in seconds)." " Note that 0 will enable all tests", type=int), parser.add_argument("-c", "--config", dest="config", help="This is DEPRECATED, prefer using the testsuite format" " to configure testsuites") parser.add_argument("-vg", "--valgrind", dest="valgrind", action="store_true", help="Run the tests inside Valgrind") parser.add_argument("--gdb", dest="gdb", action="store_true", help="Run the tests inside gdb (implies" " --output-dir=stdout and --jobs=1)") parser.add_argument("-nd", "--no-display", dest="no_display", action="store_true", help="Run the tests without outputting graphics" " on any display. It tries to run all graphical operation" " in a virtual framebuffer." " Note that it is currently implemented only" " for the X server thanks to Xvfb (which is requeried in that case)") dir_group = parser.add_argument_group( "Directories and files to be used by the launcher") parser.add_argument('--xunit-file', action='store', dest='xunit_file', metavar="FILE", help=("Path to xml file to store the xunit report in. " "Default is LOGSDIR/xunit.xml")) dir_group.add_argument("-M", "--main-dir", dest="main_dir", help="Main directory where to put files. Default is %s" % DEFAULT_MAIN_DIR) dir_group.add_argument("--testsuites-dir", dest="testsuites_dir", help="Directory where to look for testsuites. Default is %s" " Note that GstValidate expect testsuite file to have .testsuite" " as an extension in this folder." % DEFAULT_TESTSUITES_DIR) dir_group.add_argument("-o", "--output-dir", dest="output_dir", help="Directory where to store logs and rendered files. Default is MAIN_DIR") dir_group.add_argument("-l", "--logs-dir", dest="logsdir", help="Directory where to store logs, default is OUTPUT_DIR/logs.") dir_group.add_argument("-R", "--render-path", dest="dest", help="Set the path to which projects should be rendered, default is OUTPUT_DIR/rendered") dir_group.add_argument("-p", "--medias-paths", dest="paths", action="append", help="Paths in which to look for media files") dir_group.add_argument("-a", "--clone-dir", dest="clone_dir", help="Paths where to clone the testuite to run " " default is MAIN_DIR/gst-integration-testsuites") dir_group.add_argument("-rl", "--redirect-logs", dest="redirect_logs", help="Redirect logs to 'stdout' or 'sdterr'.") dir_group.add_argument("-j", "--jobs", dest="num_jobs", help="Number of tests to execute simultaneously", type=int) http_server_group = parser.add_argument_group( "Handle the HTTP server to be created") http_server_group.add_argument( "--http-server-port", dest="http_server_port", help="Port on which to run the http server on localhost") http_server_group.add_argument( "--http-bandwith-limitation", dest="http_bandwith", help="The artificial bandwith limitation to introduce to the local server (in Bytes/sec) (default: 1 MBps)") http_server_group.add_argument( "-s", "--folder-for-http-server", dest="http_server_dir", help="Folder in which to create an http server on localhost. Default is PATHS") http_server_group.add_argument("--http-only", dest="httponly", action='store_true', help="Start the http server and quit") assets_group = parser.add_argument_group("Handle remote assets") assets_group.add_argument( "--get-assets-command", dest="get_assets_command", help="Command to get assets") assets_group.add_argument("--remote-assets-url", dest="remote_assets_url", help="Url to the remote assets (default:%s)" % DEFAULT_GST_QA_ASSETS_REPO) assets_group.add_argument("-S", "--sync", dest="sync", action="store_true", help="Synchronize asset repository") assets_group.add_argument("-fs", "--force-sync", dest="force_sync", action="store_true", help="Synchronize asset repository reseting any change that might have" " happened in the testsuite") assets_group.add_argument("--sync-all", dest="sync_all", action="store_true", help="Synchronize asset repository," " including big media files") assets_group.add_argument("--usage", action=PrintUsage, help="Print usage documentation") loggable.init("GST_VALIDATE_LAUNCHER_DEBUG", True, False) tests_launcher = _TestsLauncher(libsdir) tests_launcher.add_options(parser) if _help_message == HELP and which(LESS): tmpf = tempfile.NamedTemporaryFile() parser.print_help(file=tmpf) exit(os.system("%s %s" % (LESS, tmpf.name))) options = LauncherConfig() parser.parse_args(namespace=options) if not options.cleanup(): exit(1) if options.remote_assets_url and options.sync and not os.path.exists(options.clone_dir): if not download_assets(options): exit(1) # Ensure that the scenario manager singleton is ready to be used ScenarioManager().config = options tests_launcher.set_settings(options, []) tests_launcher.list_tests() if options.list_tests: l = tests_launcher.tests for test in l: printc(test) printc("\nNumber of tests: %d" % len(l), Colors.OKGREEN) return 0 httpsrv = HTTPServer(options) if tests_launcher.needs_http_server() or options.httponly is True: httpsrv.start() vfb_server = get_virual_frame_buffer_server(options) if options.no_display: res = vfb_server.start() if res[0] is False: printc("Could not start virtual frame server: %s" % res[1], Colors.FAIL) exit(1) os.environ["DISPLAY"] = vfb_server.display_id if options.httponly is True: print("Running HTTP server only") return e = None try: tests_launcher.run_tests() except Exception as e: pass finally: tests_launcher.final_report() httpsrv.stop() vfb_server.stop() if e is not None: raise return 0
def main(): parser = argparse.ArgumentParser(formatter_class=Formatter, prog='gst-validate-launcher', description=HELP) parser.add_argument("-d", "--debug", dest="debug", action="store_true", default=False, help="Let user debug the process on timeout") parser.add_argument("-f", "--forever", dest="forever", action="store_true", default=False, help="Keep running tests until one fails") parser.add_argument("-F", "--fatal-error", dest="fatal_error", action="store_true", default=False, help="Stop on first fail") parser.add_argument("-t", "--wanted-tests", dest="wanted_tests", default=[], action="append", help="Define the tests to execute, it can be a regex" " if it contains defaults_only, only default scenarios" " will be executed") parser.add_argument("-b", "--blacklisted-tests", dest="blacklisted_tests", default=[], action="append", help="Define the tests not to execute, it can be a regex.") parser.add_argument("-L", "--list-tests", dest="list_tests", action="store_true", default=False, help="List tests and exit") parser.add_argument("-m", "--mute", dest="mute", action="store_true", default=False, help="Mute playback output, which mean that we use " "a fakesink") parser.add_argument("-n", "--no-color", dest="no_color", action="store_true", default=False, help="Set it to output no colored text in the terminal") parser.add_argument("-g", "--generate-media-info", dest="generate_info", action="store_true", default=False, help="Set it in order to generate the missing .media_infos files") parser.add_argument("-lt", "--long-test-limit", dest="long_limit", default=utils.LONG_TEST, action='store', help="Defines the limite from which a test is concidered as long (is seconds)"), dir_group = parser.add_argument_group("Directories and files to be used by the launcher") parser.add_argument('--xunit-file', action='store', dest='xunit_file', metavar="FILE", default=None, help=("Path to xml file to store the xunit report in. " "Default is LOGSDIR/xunit.xml")) dir_group.add_argument("-M", "--main-dir", dest="main_dir", default=DEFAULT_MAIN_DIR, help="Main directory where to put files. Default is %s" % DEFAULT_MAIN_DIR) dir_group.add_argument("-o", "--output-dir", dest="output_dir", default=None, help="Directory where to store logs and rendered files. Default is MAIN_DIR") dir_group.add_argument("-l", "--logs-dir", dest="logsdir", default=None, help="Directory where to store logs, default is OUTPUT_DIR/logs") dir_group.add_argument("-R", "--render-path", dest="dest", default=None, help="Set the path to which projects should be rendered, default is OUTPUT_DIR/rendered") dir_group.add_argument("-p", "--medias-paths", dest="paths", action="append", default=None, help="Paths in which to look for media files, default is MAIN_DIR/gst-qa-assets/media") dir_group.add_argument("-a", "--clone-dir", dest="clone_dir", default=None, help="Paths in which to look for media files, default is MAIN_DIR/gst-qa-assets") http_server_group = parser.add_argument_group("Handle the HTTP server to be created") http_server_group.add_argument("--http-server-port", dest="http_server_port", default=8079, help="Port on which to run the http server on localhost") http_server_group.add_argument("-s", "--folder-for-http-server", dest="http_server_dir", default=None, help="Folder in which to create an http server on localhost. Default is PATHS") http_server_group.add_argument("--http-only", dest="httponly", default=False, action='store_true', help="Start the http server and quit") assets_group = parser.add_argument_group("Handle remote assets") assets_group.add_argument("-u", "--update-assets-command", dest="update_assets_command", default="git fetch %s && git checkout FETCH_HEAD && git annex get ." % (DEFAULT_GST_QA_ASSETS_REPO, ), help="Command to update assets") assets_group.add_argument("--get-assets-command", dest="get_assets_command", default="git clone", help="Command to get assets") assets_group.add_argument("--remote-assets-url", dest="remote_assets_url", default=DEFAULT_GST_QA_ASSETS_REPO, help="Url to the remote assets (default:%s)" % DEFAULT_GST_QA_ASSETS_REPO) assets_group.add_argument("-S", "--sync", dest="sync", action="store_true", default=False, help="Synchronize asset repository") assets_group.add_argument("--usage", dest="sync", action=PrintUsage, help="Print usage documentation") loggable.init("GST_VALIDATE_LAUNCHER_DEBUG", True, False) tests_launcher = _TestsLauncher() tests_launcher.add_options(parser) (options, args) = parser.parse_known_args() # Get absolute path for main_dir and base everything on that options.main_dir = os.path.abspath(options.main_dir) # default for output_dir is MAINDIR if not options.output_dir: options.output_dir = options.main_dir else: options.output_dir = os.path.abspath(options.output_dir) # other output directories if options.logsdir is None: options.logsdir = os.path.join(options.output_dir, "logs") if options.xunit_file is None: options.xunit_file = os.path.join(options.logsdir, "xunit.xml") if options.dest is None: options.dest = os.path.join(options.output_dir, "rendered") if not os.path.exists(options.dest): os.makedirs(options.dest) if urlparse.urlparse(options.dest).scheme == "": options.dest = path2url(options.dest) if options.no_color: utils.desactivate_colors() if options.clone_dir is None: options.clone_dir = os.path.join(options.main_dir, QA_ASSETS) if options.paths is None: options.paths = os.path.join(options.clone_dir, MEDIAS_FOLDER) if options.http_server_dir is None: options.http_server_dir = options.paths if not options.sync and not os.path.exists(options.clone_dir) and \ options.clone_dir == os.path.join(options.clone_dir, MEDIAS_FOLDER): printc("Media path (%s) does not exists. Forgot to run --sync ?" % options.clone_dir, Colors.FAIL, True) return -1 blacklisted = tests_launcher.get_blacklisted() if blacklisted: msg = "Currently 'hardcoded' blacklisted tests:\n" for name, bug in blacklisted: options.blacklisted_tests.append(name) msg += " + %s \n --> bug: %s\n\n" % (name, bug) printc(msg, Colors.FAIL, True) tests_launcher.set_settings(options, args) if options.remote_assets_url and options.sync: if os.path.exists(options.clone_dir): launch_command("cd %s && %s" % (options.clone_dir, options.update_assets_command), fails=True) else: launch_command("%s %s %s" % (options.get_assets_command, options.remote_assets_url, options.clone_dir), fails=True) launch_command("cd %s && %s" % (options.clone_dir, options.update_assets_command), fails=True) # Ensure that the scenario manager singleton is ready to be used ScenarioManager().config = options tests_launcher.list_tests() if options.list_tests: l = tests_launcher.tests l.sort() for test in l: printc(test) printc("\nNumber of tests: %d" % len (l), Colors.OKGREEN) return 0 httpsrv = HTTPServer(options) if tests_launcher.needs_http_server() or options.httponly is True: httpsrv.start() if options.httponly is True: print "Running HTTP server only" return e = None try: tests_launcher.run_tests() tests_launcher.final_report() except Exception as e: pass finally: httpsrv.stop() if e is not None: raise return 0
def listFolder(parentPath, folder, conn, cursor, service): # Check if folder should be skipped folderPath = f"{parentPath}/{folder['name']}" if re.search(SKIP_PATTERN, folder['name']) != None: printc(f">> Skipping {folderPath}", 'WARNING') return # Check if folder has been explored res = cursor.execute( f"SELECT completed FROM file WHERE id='{folder['id']}'").fetchone() if res != None and res[0]: printc(f">> Already explored {folderPath}", 'WARNING') return # Insert folder record cursor.execute( "INSERT INTO file VALUES (?,?,?,?,'folder','false') ON CONFLICT(id) DO NOTHING", (folderPath, folder['id'], folder['webViewLink'], folder['owners'][0]['emailAddress'])) # List folder content printc(f'> LISTING {folderPath}', 'HEADER') items = service.files().list( q=f"'{folder['id']}' in parents", fields="files(id,name,mimeType,webViewLink,owners(emailAddress))" ).execute().get('files', []) for item in items: try: printc(f">> Inserting file {folderPath}/{item['name']}", 'OKGREEN') if item['mimeType'] == 'application/vnd.google-apps.folder': # Folder conn.commit() # Commit before going to another folder listFolder(folderPath, item, conn, cursor, service) else: # File filePath = f"{folderPath}/{item['name']}" cursor.execute( "INSERT INTO file VALUES (?,?,?,?,'file','true') ON CONFLICT(id) DO NOTHING", (filePath, item['id'], item['webViewLink'], item['owners'][0]['emailAddress'])) except Error as error: printc(f">> Failed parsing {folderPath}/{item['name']}", 'FAIL') printc(f">> {error}", 'FAIL') pass # Mark folder as explored cursor.execute(f"UPDATE file SET completed=true WHERE id='{folder['id']}'") conn.commit() printc(f'> COMPLETED {folderPath}', 'HEADER')
def cleanup(self): """ Cleanup the options looking after user options have been parsed """ # Get absolute path for main_dir and base everything on that self.main_dir = os.path.abspath(self.main_dir) # default for output_dir is MAINDIR if not self.output_dir: self.output_dir = self.main_dir else: self.output_dir = os.path.abspath(self.output_dir) # other output directories if self.logsdir in ['stdout', 'stderr']: # Allow -l stdout/stderr to work like -rl stdout/stderr self.redirect_logs = self.logsdir self.logsdir = None if self.logsdir is None: self.logsdir = os.path.join(self.output_dir, "logs") if self.xunit_file is None: self.xunit_file = os.path.join(self.logsdir, "xunit.xml") if self.dest is None: self.dest = os.path.join(self.output_dir, "rendered") if not os.path.exists(self.dest): os.makedirs(self.dest) if not os.path.exists(self.logsdir): os.makedirs(self.logsdir) if not self.redirect_logs in ['stdout', 'stderr', False]: printc("Log redirection (%s) must be either 'stdout' or 'stderr'." % self.redirect_logs, Colors.FAIL, True) return False if urlparse.urlparse(self.dest).scheme == "": self.dest = path2url(self.dest) if self.no_color: utils.desactivate_colors() if self.clone_dir is None: self.clone_dir = os.path.join(self.main_dir, QA_ASSETS) if not isinstance(self.paths, list): self.paths = [self.paths] if self.generate_info_full is True: self.generate_info = True if self.sync_all is True: self.sync = True if self.update_assets_command == DEFAULT_SYNC_ASSET_COMMAND: self.update_assets_command = DEFAULT_SYNC_ALL_ASSET_COMMAND if not self.sync and not os.path.exists(self.clone_dir) and \ self.clone_dir == os.path.join(self.clone_dir, MEDIAS_FOLDER): printc("Media path (%s) does not exists. Forgot to run --sync ?" % self.clone_dir, Colors.FAIL, True) return False if (self.main_dir != DEFAULT_MAIN_DIR or self.clone_dir != QA_ASSETS) and \ self.testsuites_dir == DEFAULT_TESTSUITES_DIR: self.testsuites_dir = os.path.join(self.main_dir, self.clone_dir, "testsuites") return True
from online import OnlineApiClient, OnlineApiError VERSION = "1.0.0" class CriticalError(Exception): def __init__(self, message): self.message = message try: # Here's a cute birb (oiseau=birb in french) printc( """ ___ ( "> )( // ) jgs --//""-- -/------""", utils.BColors.YELLOW) printc(" " * 7 + "oiseau @{}\n".format(VERSION), utils.BColors.YELLOW + utils.BColors.BOLD) # Load config config = Config() # Check online.net api token client = OnlineApiClient(config["ONLINE_API_KEY"]) logged_in = client.auth_valid() if not logged_in: raise CriticalError("Could not log in, check your online.net API key")
def main(libsdir): parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter, prog='gst-validate-launcher', description=HELP) parser.add_argument('testsuites', metavar='N', nargs='*', help="""Lets you specify a file where the testsuite to execute is defined. In the module if you want to work with a specific test manager(s) (for example, 'ges' or 'validate'), you should define the TEST_MANAGER variable in the testsuite file (it can be a list of test manager names) In this file you should implement a setup_tests function. That function takes a TestManager and the GstValidateLauncher option as parameters and return True if it succeeded loading the tests, False otherwise. You will be able to configure the TestManager with its various methods. This function will be called with each TestManager usable, for example you will be passed the 'validate' TestManager in case the GstValidateManager launcher is avalaible. You should configure it using: * test_manager.add_scenarios: which allows you to register a list of scenario names to be run * test_manager.set_default_blacklist: Lets you set a list of tuple of the form: (@regex_defining_blacklister_test_names, @reason_for_the_blacklisting) * test_manager.add_generators: which allows you to register a list of #GstValidateTestsGenerator to be used to generate tests * test_manager.add_encoding_formats:: which allows you to register a list #MediaFormatCombination to be used for transcoding tests You can also set default values with: * test_manager.register_defaults: Sets default values for all parametters * test_manager.register_default_test_generators: Sets default values for the TestsGenerators to be used * test_manager.register_default_scenarios: Sets default values for the scenarios to be executed * test_manager.register_default_encoding_formats: Sets default values for the encoding formats to be tested Note that all testsuite should be inside python modules, so the directory should contain a __init__.py file """, default=["validate", "ges"]) parser.add_argument("-d", "--debug", dest="debug", action="store_true", help="Let user debug the process on timeout") parser.add_argument("-f", "--forever", dest="forever", action="store_true", help="Keep running tests until one fails") parser.add_argument("-F", "--fatal-error", dest="fatal_error", action="store_true", help="Stop on first fail") parser.add_argument("-t", "--wanted-tests", dest="wanted_tests", action="append", help="Define the tests to execute, it can be a regex." " If it contains defaults_only, only default scenarios" " will be executed") parser.add_argument("-b", "--blacklisted-tests", dest="blacklisted_tests", action="append", help="Define the tests not to execute, it can be a regex.") parser.add_argument("-L", "--list-tests", dest="list_tests", action="store_true", help="List tests and exit") parser.add_argument("-m", "--mute", dest="mute", action="store_true", help="Mute playback output, which means that we use " "a fakesink") parser.add_argument("-n", "--no-color", dest="no_color", action="store_true", help="Set it to output no colored text in the terminal") parser.add_argument("-g", "--generate-media-info", dest="generate_info", action="store_true", help="Set it in order to generate the missing .media_infos files") parser.add_argument("--update-media-info", dest="update_media_info", action="store_true", help="Set it in order to update exising .media_infos files") parser.add_argument( "-G", "--generate-media-info-with-frame-detection", dest="generate_info_full", action="store_true", help="Set it in order to generate the missing .media_infos files. " "It implies --generate-media-info but enabling frame detection") parser.add_argument("-lt", "--long-test-limit", dest="long_limit", action='store', help="Defines the limite from which a test is concidered as long (in seconds)" " not that 0 will enable all tests", type=int), parser.add_argument("-c", "--config", dest="config", help="This is DEPRECATED, prefer using the testsuite format" " to configure testsuites") dir_group = parser.add_argument_group( "Directories and files to be used by the launcher") parser.add_argument('--xunit-file', action='store', dest='xunit_file', metavar="FILE", help=("Path to xml file to store the xunit report in. " "Default is LOGSDIR/xunit.xml")) dir_group.add_argument("-M", "--main-dir", dest="main_dir", help="Main directory where to put files. Default is %s" % DEFAULT_MAIN_DIR) dir_group.add_argument("--testsuites-dir", dest="testsuites_dir", help="Directory where to look for testsuites. Default is %s" " Note that GstValidate expect testsuite file to have .testsuite" " as an extension in this folder." % DEFAULT_TESTSUITES_DIR) dir_group.add_argument("-o", "--output-dir", dest="output_dir", help="Directory where to store logs and rendered files. Default is MAIN_DIR") dir_group.add_argument("-l", "--logs-dir", dest="logsdir", help="Directory where to store logs, default is OUTPUT_DIR/logs.") dir_group.add_argument("-R", "--render-path", dest="dest", help="Set the path to which projects should be rendered, default is OUTPUT_DIR/rendered") dir_group.add_argument("-p", "--medias-paths", dest="paths", action="append", help="Paths in which to look for media files") dir_group.add_argument("-a", "--clone-dir", dest="clone_dir", help="Paths where to clone the testuite to run " " default is MAIN_DIR/gst-integration-testsuites") dir_group.add_argument("-rl", "--redirect-logs", dest="redirect_logs", help="Redirect logs to 'stdout' or 'sdterr'.") dir_group.add_argument("-j", "--jobs", dest="num_jobs", help="Number of tests to execute simultaneously", type=int) http_server_group = parser.add_argument_group( "Handle the HTTP server to be created") http_server_group.add_argument( "--http-server-port", dest="http_server_port", help="Port on which to run the http server on localhost") http_server_group.add_argument( "--http-bandwith-limitation", dest="http_bandwith", help="The artificial bandwith limitation to introduce to the local server (in Bytes/sec) (default: 1 MBps)") http_server_group.add_argument( "-s", "--folder-for-http-server", dest="http_server_dir", help="Folder in which to create an http server on localhost. Default is PATHS") http_server_group.add_argument("--http-only", dest="httponly", action='store_true', help="Start the http server and quit") assets_group = parser.add_argument_group("Handle remote assets") assets_group.add_argument( "-u", "--update-assets-command", dest="update_assets_command", help="Command to update assets") assets_group.add_argument( "--get-assets-command", dest="get_assets_command", help="Command to get assets") assets_group.add_argument("--remote-assets-url", dest="remote_assets_url", help="Url to the remote assets (default:%s)" % DEFAULT_GST_QA_ASSETS_REPO) assets_group.add_argument("-S", "--sync", dest="sync", action="store_true", help="Synchronize asset repository") assets_group.add_argument("--sync-all", dest="sync_all", action="store_true", help="Synchronize asset repository," " including big media files") assets_group.add_argument("--usage", action=PrintUsage, help="Print usage documentation") loggable.init("GST_VALIDATE_LAUNCHER_DEBUG", True, False) tests_launcher = _TestsLauncher(libsdir) tests_launcher.add_options(parser) options = LauncherConfig() parser.parse_args(namespace=options) if not options.cleanup(): exit(1) if options.remote_assets_url and options.sync: if os.path.exists(options.clone_dir): if not update_assets(options): exit(1) else: if not download_assets(options): exit(1) if not update_assets(options): exit(1) tests_launcher.set_settings(options, []) # Ensure that the scenario manager singleton is ready to be used ScenarioManager().config = options tests_launcher.list_tests() if options.list_tests: l = tests_launcher.tests for test in l: printc(test) printc("\nNumber of tests: %d" % len(l), Colors.OKGREEN) return 0 httpsrv = HTTPServer(options) if tests_launcher.needs_http_server() or options.httponly is True: httpsrv.start() if options.httponly is True: print "Running HTTP server only" return e = None try: tests_launcher.run_tests() except Exception as e: pass finally: tests_launcher.final_report() httpsrv.stop() if e is not None: raise return 0