def runTest(testCaseFile): testCaseFile=os.path.join(os.getwcd(),testCaseFile) if not os.path.exists(testCaseFile): logging.error("测试用例文件不存在!") sys.exit() test_case=xlrd.open_workbook(testCaseFile) table=test_case.sheet_by_index(0) errorCase=[] #用于保存接口返回的内容和http状态码 s=None for i in range(1,table.nrows): if table.cell(i,9).value.replace("\n","").replace("\r","") != "Yes": continue num= str(int(table.cell(i,0).value)).replace("\n","").replace("\r","") api_purpose=table.cell(i,1).value.replace("\n","").replace("\r","") api_host=table.cell(i,2).value.replace("\n","").replace("\r","") request_method=table.cell(i,4).value.replace("\n","").replace("\r","") requset_data_type=table.cell(i,5).value.replace("\n","").replace("\r","") request_data=table.cell(i,6).value.replace("\n","").replace("\r","") encryption=table.cell(i,7).value.replace("\n","").replace("\r","") check_point=table.cell(i,8).value if encryption == "MD5": #如果数据采用MD5加密,则优先将数据加密 request_data=json.loads(request_data) request_data["pwd"]=md5Encode(request_data["pwd"]) status,resp,s=interfaceTest(num,apipurpose,api_host,request_url,request_data,check_point,request_method,request_data_type,s) if status != 200 or check_point not in resp: #如果状态码不是200,或者返回值没有检查点的内容,那么证明接口产生错误,保存错误信息 errorCase.append((num+" "+api_purpose,str(status),"http://"+api_host+request_url,resp))
def set_environ(self): # Enforce copies of data when TEST_BIGDATA is URL input_dir = get_bigdata_root() if input_dir and check_url(input_dir): self.docopy = True # NOTE: This could be explicitly controlled using pytest fixture # but too many ways to do the same thing would be confusing. # Refine this logic if using pytest fixture. # HSTCAL cannot open remote CRDS on FTP but central storage is okay. # So use central storage if available to avoid FTP. if self.prevref is None or self.prevref.startswith(('ftp', 'http')): os.environ[self.refstr] = os.getwcd() + os.sep self.use_ftp_crds = True # Turn off Astrometry updates os.environ['ASTROMETRY_STEP_CONTROL'] = 'OFF'
def most_recent_snapshot(self): """Go to most recently created snapshot dir and get snapshot.""" cwd = os.getwcd() try: os.chdir(self.depot_) history = sorted(filter(os.path.isdir, os.listdir('.')), key=lambda d: os.stat(d).st_ctime) snap_slot = self.get_statefile_slot_() for snaplabel in history: os.chdir(snaplabel) try: snap = Snapshot(event.events.LOAD).init(snap_slot) if snap.valid(): return snaplabel finally: os.chdir('..') return None finally: os.chdir(cwd)
#!/usr/bin/env python import os import sys BASE_DIR = os.path.dirname(os.getwcd()) # 设置工作目录,使得包和模块能够正常导入 sys.path.append(BASE_DIR) from Client.core import handler if __name__ == '__mian__': handler.ArgvHandler(sys.argv)
import os os.getwcd() from decimal import Decimal a = Decimal("0.5") b = Decimal("0.4") print (a-b == Decimal("0.1")) # Заданы две клетки шахматной доски. # Если они покрашены в один цвет, то выведите слово YES, # а если в разные цвета – то NO. x1 = int(input()) y1 = int(input()) x2 = int(input()) y2 = int(input()) if abs(x1 - y1) % 2 == abs(x2 - y2) % 2: print("YES") else: print("NO") # ulitka from math import ceil h = float(input()) a = float(input()) b = float(input()) print(ceil((h-a)/(a-b)+1)) ## високосный год
if len(failed_jobs) > 0: print 'The following jobs have failed:' print '\t', failed_jobs a = raw_input('Do you want to resubmit them? [y]/[n]\n') if a == 'y' or a == 'Y' or a == 'yes': for job in failed_jobs: os.system("rm -f %s.done" % job) os.system("rm -f %s.fail" % job) os.system("rm -f %s.run" % job) os.system("rm -f %s.log" % job) if options.parametric: os.system('bsub -q 1nh -o %s/%s.log %s/%s' % (os.getcwd(), job, os.getcwd(), job)) else: os.system('bsub -q 8nh -o %s/%s.log %s/%s' % (os.getwcd(), job, os.getcwd(), job)) sys.exit() else: b = raw_input( 'There are failed jobs that haven\'t been resubmited. Do you want to continue? [y]/[n]\n' ) if b == 'n' or b == 'N' or b == 'no': sys.exit() result_dir = os.getcwd() macros_dir = os.getcwd().split('Macros')[0] + 'Macros' os.chdir(macros_dir) os.system("mkdir -p %s/plots" % (result_dir)) for card, suffix, line in config: print "-------------------------"
for dir in job_dirs: if not os.path.isfile('%s/%s/sub.sh.done'%(suffix,dir)): failed_jobs.append('%s/%s/sub.sh'%(suffix,dir)) if len(failed_jobs)>0: print 'The following jobs have failed:' print '\t', failed_jobs a = raw_input('Do you want to resubmit them? [y]/[n]\n') if a=='y' or a=='Y' or a=='yes': for job in failed_jobs: os.system("rm -f %s.done"%job) os.system("rm -f %s.fail"%job) os.system("rm -f %s.run"%job) os.system("rm -f %s.log"%job) if options.parametric: os.system('bsub -q 1nh -o %s/%s.log %s/%s'%(os.getcwd(),job,os.getcwd(),job)) else: os.system('bsub -q 8nh -o %s/%s.log %s/%s'%(os.getwcd(),job,os.getcwd(),job)) sys.exit() else: b = raw_input('There are failed jobs that haven\'t been resubmited. Do you want to continue? [y]/[n]\n') if b=='n' or b=='N' or b=='no': sys.exit() result_dir = os.getcwd() macros_dir = os.getcwd().split('Macros')[0]+'Macros' os.chdir(macros_dir) os.system("mkdir -p %s/plots"%(result_dir)) for card, suffix, line in config: print "-------------------------" print "------ Running", suffix, "-----" print "-------------------------"
topo = topotools.Topography( path=os.path.join(output_dir, "strip%s.nc" % i)) topo.read(stride=stride) topo.plot(axes=axes) return axes if __name__ == "__main__": # Input: Storm names, location to download to, plot, verbose # # # output_dir = os.getwcd() force = False verbose = False # Override download location if len(sys.argv) > 1: storm_names = sys.argv[1:] else: # TODO: Add better failure sys.exit() if name == "global_strip": strips = [-45.0, -30.0, -15.0, 0.0, 15.0, 30.0] for (i, lower_bound) in enumerate(strips): file_name = "strip%s.nc" % i urls.append(