def test_doc_shorter_than_ref(self): # check.main('./same-as-file/error-doc-shorter-than-ref/', []) with self.assertRaises(ValueError) as context: check.main('./same-as-file/error-doc-shorter-than-ref/', []) self.assertTrue( 'Check failed because doc file is shorter than reference file.' in str(context.exception))
def test_main(capsys): """Supplying a single input file should print out the correct errors.""" args = [os.path.join(fixtures_dir, 'check.dat')] check.main(args, 'emptyrc') out, err = capsys.readouterr() assert out == ('geom_continuation is true but ' + 'continuation file not found.\n')
def keyboard_input(): # Set to global for one instance, apparently cannot do at init declaration global is_curr_reading # Get user input input("\n==================================\n[USAGE] press RETURN to quit\n[USAGE] -h for HELP\n==================================\n") is_curr_reading = False # waits for input and stops reading upon recieving time.sleep(.5) check.main()
def main(args): parser = argparse.ArgumentParser( description='User facing build script for building the Shaka' ' Player Project.') parser.add_argument( '--force', '-f', help='Force building the library even if no files have changed.', action='store_true') parser.add_argument( '--debug', help='Limit which build types to build. Will at least build the debug ' 'version.', action='store_true') parser.add_argument( '--release', help='Limit which build types to build. Will at least build the ' 'release version.', action='store_true') parsed_args = parser.parse_args(args) code = gendeps.gen_deps([]) if code != 0: return code code = check.main([]) if code != 0: return code build_args = ['--name', 'compiled', '+@complete'] if parsed_args.force: build_args += ['--force'] # Create the list of build modes to build with. If the list is empty # by the end, then populate it with every mode. modes = [] modes += ['debug'] if parsed_args.debug else [] modes += ['release'] if parsed_args.release else [] # If --debug or --release are not given, build with everything. if not modes: modes += ['debug', 'release'] result = 0 for mode in modes: result = build.main(build_args + ['--mode', mode]) # If a build fails then there is no reason to build the other modes. if result: break return result
def main(args): parser = argparse.ArgumentParser( description='User facing build script for building the Shaka' ' Player Project.') parser.add_argument( '--force', '-f', help='Force building the library even if no files have changed.', action='store_true') parser.add_argument( '--debug', help='Limit which build types to build. Will at least build the debug ' 'version.', action='store_true') parser.add_argument( '--release', help='Limit which build types to build. Will at least build the ' 'release version.', action='store_true') parsed_args = parser.parse_args(args) code = gendeps.gen_deps([]) if code != 0: return code code = check.main([]) if code != 0: return code build_args = ['--name', 'compiled', '+@complete'] if parsed_args.force: build_args += ['--force'] # Create the list of build modes to build with. If the list is empty # by the end, then populate it with every mode. modes = [] modes += ['--debug'] if parsed_args.debug else [] modes += ['--release'] if parsed_args.release else [] # If --debug or --release are not given, build with everything. if not modes: modes += ['--debug', '--release'] result = 0 for mode in modes: result = build.main(build_args + [mode]) # If a build fails then there is no reason to build the other modes. if result: break return result
def startcheck(self): if self.fileinstr != '' and self.fileoutstr != '': docheck = check.main() if docheck.check(self, self.fileinstr, self.fileoutstr) == True: self.alertTrue() else: self.alertFalse() else: self.alertnofile()
def main(_): code = gendeps.genDeps([]) if code != 0: return code code = check.main([]) if code != 0: return code return build.main(['--name', 'compiled', '+@complete'])
def test_main(): """ Testing main function of check.py """ result = main() assert len(result) == 6 assert np.array_equal( result.iloc[:, 1].values, np.array([245.00, 355.25, 461.50, 416.75, 334.75, 338.75]), ) assert np.array_equal(result.iloc[:, 2].values, np.array([237.25, 185.25, 81, 97.25, 65.75, 172]))
def main(args): code = gendeps.gen_deps([]) if code != 0: return code code = check.main([]) if code != 0: return code build_args = ['--name', 'compiled', '+@complete'] if '--force' in args: build_args.append('--force') return build.main(build_args)
def add_groups (campaign_name, restaurant_id, name): #добавляет группу объявлений в нужную кампанию data_json = json_parse.main() adwords_client = adwords.AdWordsClient.LoadFromStorage('googleads.yaml') #здесь хранятся название и айди кампании with open ('campaign_name_id.csv', 'r') as a: reader = csv.reader(a, delimiter='\n') for data in reader: name_id=data[0].split(',') #лист хранит найзвание и айди if (campaign_name==name_id[0]): #проверяет название кампании с названием кампании в файле CAMPAIGN_ID = '%s' % name_id[1] #если они равны то достает кампании айди print("CAMPAIGN_ID {}, campaign name {}".format(CAMPAIGN_ID, campaign_name)) checked_id=check.main(restaurant_id) #проверяет залит ли этот ресторан if (checked_id==True): #если True значит не залит и нужно добавлять группу объявлений print("Начинаю заливать") add_ad_groups.main(adwords_client, CAMPAIGN_ID, restaurant_id, name, campaign_name) #заливает группу объявлений
def main(args): code = gendeps.gen_deps([]) if code != 0: return code code = check.main([]) if code != 0: return code build_args = ['--name', 'compiled', '+@complete'] if '--force' in args: build_args.append('--force') if '--debug' in args or '--release' not in args: if build.main(build_args + ['--debug']) != 0: return 1 if '--release' in args or '--debug' not in args: if build.main(build_args) != 0: return 1 return 0
def main(client, campaign_id, id, name, campaign_name): now = datetime.datetime.now() date = now.strftime( "%Y-%m-%d %H:%M" ) #берет время для google sheet, чтоб знать когда залилась группа ad_groups_name_id = dict() for_google_sheet = [] ids = [] ad_group_service = client.GetService('AdGroupService', version='v201809') if (check.main(id) == True ): #проверяет есть ли эта группа в adwords по айди operations = [{ 'operator': 'ADD', 'operand': { 'campaignId': campaign_id, #айди кампании в которую заливать 'name': '[{}]{}'.format(id, name), #это название группы 'status': 'PAUSED', 'biddingStrategyConfiguration': { 'bids': [{ 'xsi_type': 'CpaBid', #целевая цена за конверсию 'bid': { 'microAmount': 2500000 #2.5 dollars ставка }, }] }, 'settings': [{ 'xsi_type': 'TargetingSetting', 'details': [ { 'xsi_type': 'TargetingSettingDetail', 'criterionTypeGroup': 'PLACEMENT', 'targetAll': 'false', }, { 'xsi_type': 'TargetingSettingDetail', 'criterionTypeGroup': 'VERTICAL', 'targetAll': 'true', }, ] }] } }] try: ad_groups = ad_group_service.mutate(operations) for ad_group in ad_groups['value']: print('Ad group with name "%s" and id "%s" was added.' % (ad_group['name'], ad_group['id'])) ad_groups_name_id.update( {ad_group['name']: ad_group['id']}) #сохраняет айди и название группы в лист for_google_sheet.append( [ad_group['name'], date, campaign_name] ) #сохраняет айди, название группы, время, название кампании в лист ids.append(["[{}]".format(ad_group['id']), 0]) except Exception as exception: #print("hello i am exceprion", exception) if exception == "[AdGroupServiceError.DUPLICATE_ADGROUP_NAME @ operations[0].operand.name; trigger:'[{}]{}']".format( id, name): print("I am error just pass") check.add(id) pass #assert type(exception).__name__ == 'NameError' #assert exception.__class__.__name__ == 'NameError' googlesheet.main(for_google_sheet) #отправляет данные в google sheet with open('ad_groups_name_id.csv', 'a') as f: #сохраняет в файл данные r = csv.reader(f, delimiter="\n") w = csv.writer(f) w.writerows(ad_groups_name_id.items())
def main(args): parser = argparse.ArgumentParser( description='User facing build script for building the Shaka' ' Player Project.') parser.add_argument( '--locales', type=str, nargs='+', default=generateLocalizations.DEFAULT_LOCALES, help='The list of locales to compile in (default %(default)r)') parser.add_argument( '--fix', help='Automatically fix style violations.', action='store_true') parser.add_argument( '--force', '-f', help='Force building the library even if no files have changed.', action='store_true') parser.add_argument( '--debug', help='Limit which build types to build. Will at least build the debug ' 'version.', action='store_true') parser.add_argument( '--release', help='Limit which build types to build. Will at least build the ' 'release version.', action='store_true') parsed_args = parser.parse_args(args) # Make the dist/ folder, ignore errors. base = shakaBuildHelpers.get_source_base() try: os.mkdir(os.path.join(base, 'dist')) except OSError: pass # Generate localizations before running gendeps, so the output is available # to the deps system. # TODO(#1858): It might be time to look at a third-party build system. localizations = compiler.GenerateLocalizations(parsed_args.locales) if not localizations.generate(parsed_args.force): return 1 if gendeps.main([]) != 0: return 1 check_args = [] if parsed_args.fix: check_args += ['--fix'] if parsed_args.force: check_args += ['--force'] if check.main(check_args) != 0: return 1 docs_args = [] if parsed_args.force: docs_args += ['--force'] if docs.main(docs_args) != 0: return 1 if not compile_less('ui', 'controls', parsed_args): return 1; # if not compile_less('demo', 'demo', parsed_args): # return 1 build_args_with_ui = ['--name', 'ui', '+@complete'] build_args_with_ui += ['--locales'] + parsed_args.locales build_args_without_ui = ['--name', 'compiled', '+@complete', '-@ui'] if parsed_args.force: build_args_with_ui += ['--force'] build_args_without_ui += ['--force'] # Create the list of build modes to build with. If the list is empty # by the end, then populate it with every mode. modes = [] modes += ['debug'] if parsed_args.debug else [] modes += ['release'] if parsed_args.release else [] # If --debug or --release are not given, build with everything. if not modes: modes += ['debug', 'release'] for mode in modes: # Complete build includes the UI library, but it is optional and player lib # should build and work without it as well. # First, build the full build (UI included) and then build excluding UI. for build_args in [build_args_with_ui, build_args_without_ui]: if build.main(build_args + ['--mode', mode]) != 0: return 1 is_debug = mode == 'debug' if not apps.build_all(parsed_args.force, is_debug): return 1 return 0
if isHG: if rev is None: run('hg diff > diffsHG.x') else: run('hg diff -r %s > diffsHG.x' % rev) f = open('diffsHG.x', 'rb') fOut = open('diffs.x', 'wb') while True: line = f.readline() if line == '': break if line.startswith('diff -r'): fOut.write('Index: %s' % line[21:]) else: line = line.replace('--- a/', '--- ') line = line.replace('+++ b/', '+++ ') fOut.write(line) f.close() fOut.close() else: run('svn diff > diffs.x') if '-check' in sys.argv: check.main('diffs.x') patchOut = '/x/tmp/patch/LUCENE-%s.patch' % issueNumber shutil.copy2('diffs.x', patchOut) print 'Saved patch to %s' % patchOut
def test_skip_doc_ref(self): check.main('./same-as-file/skip-doc-ref/', [])
# from variable import Variable import util import os import check tenant = '' varname = '' var = Variable(tenant, varname) variables = var.get_all_vars() for i in range(0, len(variables['hits']['hits'])): tenant = variables['hits']['hits'][i]['_source']['tenant'] varname = variables['hits']['hits'][i]['_source']['varname'] lapse = variables['hits']['hits'][i]['_source']['lapse'] print(variables['hits']['hits'][i]['_source']['tenant'], variables['hits']['hits'][i]['_source']['varname'], variables['hits']['hits'][i]['_source']['lapse']) now = util.get_seg_epoch_now() var_last_ts = Variable(tenant, varname) last_ts = var_last_ts.get_last_ts( ) #### <========= obtiene el timestamp de la ultima medicion print("Ultimo instante medido para :", varname, " fue:", last_ts) if (now - last_ts >= lapse): print("revisare :", tenant, varname) check.main(tenant, varname)
def test_different(self): with self.assertRaises(ValueError) as context: check.main("./same-as-file/error-doc-different-from-ref/", []) self.assertTrue( 'Check failed because doc file content is not the same as that of reference file.' in str(context.exception))
def test_basic(self): check.main('./same-as-file/simple/', [])
def test_failure(self): with self.assertRaises(ValueError) as context: check.main('./file-same-as-stdout/failure/', []) self.assertTrue('Check file-same-as-stdout failed' in str( context.exception))
exit(1) #reading other pars MODE = os.environ.get('MODE') MINUTES = int(os.environ.get('MINUTES') or "0") BOOK_URL = os.environ.get('BOOK_URL') PAGE_NAME = os.environ.get('PAGE_NAME') PASSWORD = os.environ.get('PASSWORD') #creating config f = open('user-config.py','w') f.write('# -*- coding: utf-8 -*-\n') f.write("mylang='"+ lang+"'\n") f.write("family='wikitolearn'\n") f.write("console_encoding = 'utf-8'\n") f.write('password_file = "./passwordFile.txt"\n') f.write('usernames = {}\n') f.write('usernames[family] = {}\n') f.write('usernames[family][mylang] = u"WikiToBot"\n') f.close() #creating password_file p = open('passwordFile.txt','w') p.write('("WikiToBot", "'+ PASSWORD +'")\n') p.close() import check #star process check.main(MODE, MINUTES, BOOK_URL, PAGE_NAME)
print('Production: it,en,pool') print('Testing: devit,deven,devpool') print('Local: localit,localen,localpool') exit(1) #reading params PASSWORD = os.environ.get('PASSWORD') MODE = os.environ.get('MODE') #creating config f = open('user-config.py', 'w') f.write('# -*- coding: utf-8 -*-\n') f.write("mylang='" + lang + "'\n") f.write("family='wikitolearn'\n") f.write("console_encoding = 'utf-8'\n") f.write('password_file = "./passwordFile.txt"\n') f.write('usernames = {}\n') f.write('usernames[family] = {}\n') f.write('usernames[family][mylang] = u"WikiToBot"\n') f.close() #creating password_file p = open('passwordFile.txt', 'w') p.write('("WikiToBot", "' + PASSWORD + '")\n') p.close() import check #star process check.main(MODE)
def main(args): parser = argparse.ArgumentParser( description='User facing build script for building the Shaka' ' Player Project.') parser.add_argument( '--locales', type=str, nargs='+', default=generateLocalizations.DEFAULT_LOCALES, help='The list of locales to compile in (default %(default)r)') parser.add_argument( '--fix', help='Automatically fix style violations.', action='store_true') parser.add_argument( '--force', '-f', help='Force building the library even if no files have changed.', action='store_true') parser.add_argument( '--debug', help='Limit which build types to build. Will at least build the debug ' 'version.', action='store_true') parser.add_argument( '--release', help='Limit which build types to build. Will at least build the ' 'release version.', action='store_true') parsed_args = parser.parse_args(args) # Make the dist/ folder, ignore errors. base = shakaBuildHelpers.get_source_base() try: os.mkdir(os.path.join(base, 'dist')) except OSError: pass # Generate localizations before running gendeps, so the output is available # to the deps system. # TODO(#1858): It might be time to look at a third-party build system. localizations = compiler.GenerateLocalizations(parsed_args.locales) if not localizations.generate(parsed_args.force): return 1 if gendeps.main([]) != 0: return 1 check_args = [] if parsed_args.fix: check_args += ['--fix'] if parsed_args.force: check_args += ['--force'] if check.main(check_args) != 0: return 1 docs_args = [] if parsed_args.force: docs_args += ['--force'] if docs.main(docs_args) != 0: return 1 if not compile_less('ui', 'controls', parsed_args): return 1; if not compile_less('demo', 'demo', parsed_args): return 1 build_args_with_ui = ['--name', 'ui', '+@complete'] build_args_with_ui += ['--locales'] + parsed_args.locales build_args_without_ui = ['--name', 'compiled', '+@complete', '-@ui'] if parsed_args.force: build_args_with_ui += ['--force'] build_args_without_ui += ['--force'] # Create the list of build modes to build with. If the list is empty # by the end, then populate it with every mode. modes = [] modes += ['debug'] if parsed_args.debug else [] modes += ['release'] if parsed_args.release else [] # If --debug or --release are not given, build with everything. if not modes: modes += ['debug', 'release'] for mode in modes: # Complete build includes the UI library, but it is optional and player lib # should build and work without it as well. # First, build the full build (UI included) and then build excluding UI. for build_args in [build_args_with_ui, build_args_without_ui]: if build.main(build_args + ['--mode', mode]) != 0: return 1 is_debug = mode == 'debug' if not apps.build_all(parsed_args.force, is_debug): return 1 return 0
print ('Production: it,en,pool') print ('Testing: devit,deven,devpool') print ('Local: localit,localen,localpool') exit(1) #reading params PASSWORD = os.environ.get('PASSWORD') MODE = os.environ.get('MODE') #creating config f = open('user-config.py','w') f.write('# -*- coding: utf-8 -*-\n') f.write("mylang='"+ lang+"'\n") f.write("family='wikitolearn'\n") f.write("console_encoding = 'utf-8'\n") f.write('password_file = "./passwordFile.txt"\n') f.write('usernames = {}\n') f.write('usernames[family] = {}\n') f.write('usernames[family][mylang] = u"WikiToBot"\n') f.close() #creating password_file p = open('passwordFile.txt','w') p.write('("WikiToBot", "'+ PASSWORD +'")\n') p.close() import check #star process check.main(MODE)
def main(args): parser = argparse.ArgumentParser( description='User facing build script for building the Shaka' ' Player Project.') parser.add_argument('--fix', help='Automatically fix style violations.', action='store_true') parser.add_argument( '--force', '-f', help='Force building the library even if no files have changed.', action='store_true') parser.add_argument( '--debug', help='Limit which build types to build. Will at least build the debug ' 'version.', action='store_true') parser.add_argument( '--release', help='Limit which build types to build. Will at least build the ' 'release version.', action='store_true') parsed_args = parser.parse_args(args) if gendeps.main([]) != 0: return 1 check_args = [] if parsed_args.fix: check_args += ['--fix'] if parsed_args.force: check_args += ['--force'] if check.main(check_args) != 0: return 1 docs_args = [] if parsed_args.force: docs_args += ['--force'] if docs.main(docs_args) != 0: return 1 src = os.path.join(shakaBuildHelpers.get_source_base(), 'ui', 'controls.less') output = os.path.join(shakaBuildHelpers.get_source_base(), 'dist', 'controls.css') less = compiler.Less([src], output) if not less.compile(parsed_args.force): return 1 build_args_with_ui = ['--name', 'ui', '+@complete'] build_args_without_ui = ['--name', 'compiled', '+@complete', '-@ui'] if parsed_args.force: build_args_with_ui += ['--force'] build_args_without_ui += ['--force'] # Create the list of build modes to build with. If the list is empty # by the end, then populate it with every mode. modes = [] modes += ['debug'] if parsed_args.debug else [] modes += ['release'] if parsed_args.release else [] # If --debug or --release are not given, build with everything. if not modes: modes += ['debug', 'release'] for mode in modes: # Complete build includes the UI library, but it is optional and player lib # should build and work without it as well. # First, build the full build (UI included) and then build excluding UI. for build_args in [build_args_with_ui, build_args_without_ui]: if build.main(build_args + ['--mode', mode]) != 0: return 1 is_debug = mode == 'debug' if not apps.build_all(parsed_args.force, is_debug): return 1 return 0
#!python import check if __name__ == '__main__': check.main()
def test_basic(self): check.main('./file-same-as-stdout/success/', [])
pass check_minion_job_count = check_minion_job_count + 1 if check_minion_job_count == 9: print '检查9次发现jid还在运行,杀掉僵死进程!' sapi.target_remote_execution1(host['hostname'],'saltutil.kill_job',minionjid) time.sleep(12) marahost = dev_host_list[-1]['hostname'] marathon_dir = ('bash /xinguang/%s/bin/tomcat/marathon.sh' %(app_name)) run_marathon = sapi.remote_execution(marahost,'cmd.run','%s %s %s %s' %(marathon_dir,app_name,deploy_env,project)) if run_marathon is not None and "No such file" in run_marathon: print "此项目为传统方式部署,无法找到marathon相关文件,不执行marathon方式检查!" sys.exit() else: time.sleep(60) count = 1 while (count < 10): time.sleep(35) result = check.main(deploy_env,project,app_name) if [ result == 1 ]: print '第%i次检测结果:服务正在部署中,请稍后......' %(count) count = count + 1 print "检测服务多次,状态一直为部署中,服务启动可能失败,请自行查看业务启动日志!" sys.exit(1) if __name__ == "__main__": main()