Best Python code snippet using pyatom_python
plot_params.py
Source:plot_params.py
1"""2===================3plot_params.py4Erica Lastufka 16.10.175===================6Get data to dictionaries. plot.7"""8import glob9import pickle10import os11#from edge_and_hough import windows as windowsf12#from edge_and_hough import windowsr13#print windowsf[0]['pitch'],windowsf[0]['nominal angle']14def load_dict(front_dir='/Users/wheatley/Documents/Solar/MiSolFA/prototypes/mw469sub2737_2017_06_01',rear_dir='/Users/wheatley/Documents/Solar/MiSolFA/prototypes/mw469sub2765_2017_06_02',mag=5.0):15 windowsf=[{'number':11,'pitch':89.6752, 'nominal angle':-44.79357},16 {'number':21,'pitch':90.326, 'nominal angle': 45.20793},17 {'number':12,'pitch':22.4797,'nominal angle': 44.94825},18 {'number':22,'pitch':22.5203,'nominal angle':-45.05184},19 {'number':31,'pitch':45.0814, 'nominal angle':-45.10378},20 {'number':41,'pitch':44.9187, 'nominal angle': 44.8966},21 {'number':32,'pitch':18.013, 'nominal angle': 45.04146},22 {'number':42,'pitch':17.987, 'nominal angle':-44.95859},23 {'number':33,'pitch':29.9639, 'nominal angle':-44.93102},24 {'number':43,'pitch':30.0362, 'nominal angle': 45.06914},25 {'number':34,'pitch':14.991, 'nominal angle': 44.96549},26 {'number':44,'pitch':15.009, 'nominal angle':-45.03455}]27 windowsr=[{'number':11,'pitch':90.326, 'nominal angle':-45.20793},28 {'number':21,'pitch':89.6752, 'nominal angle': 44.79357},29 {'number':12,'pitch':22.5203,'nominal angle': 45.05184},30 {'number':22,'pitch':22.4797,'nominal angle':-44.94825},31 {'number':31,'pitch':44.9187, 'nominal angle':-44.8966},32 {'number':41,'pitch':45.0814, 'nominal angle': 45.10378},33 {'number':32,'pitch':17.987, 'nominal angle': 44.95859},34 {'number':42,'pitch':18.013, 'nominal angle':-45.04146},35 {'number':33,'pitch':30.0362, 'nominal angle':-45.06914},36 {'number':43,'pitch':29.9639, 'nominal angle': 44.93102},37 {'number':34,'pitch':15.009, 'nominal angle': 45.03455},38 {'number':44,'pitch':14.991, 'nominal angle':-44.96549}] #dectector side angle for ease, windows swapped...39 40 windows=[{'side':'f','number':11,'pitch':windowsf[0]['pitch'], 'nangle':windowsf[0]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},41 {'side':'f','number':21,'pitch':windowsf[1]['pitch'], 'nangle': windowsf[1]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},42 {'side':'f','number':12,'pitch':windowsf[2]['pitch'],'nangle': windowsf[2]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},43 {'side':'f','number':22,'pitch':windowsf[3]['pitch'],'nangle':windowsf[3]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},44 {'side':'f','number':31,'pitch':windowsf[4]['pitch'], 'nangle':windowsf[4]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},45 {'side':'f','number':41,'pitch':windowsf[5]['pitch'], 'nangle': windowsf[5]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},46 {'side':'f','number':32,'pitch':windowsf[6]['pitch'], 'nangle':windowsf[6]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},47 {'side':'f','number':42,'pitch':windowsf[7]['pitch'], 'nangle':windowsf[7]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},48 {'side':'f','number':33,'pitch':windowsf[8]['pitch'], 'nangle':windowsf[8]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},49 {'side':'f','number':43,'pitch':windowsf[9]['pitch'], 'nangle': windowsf[9]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},50 {'side':'f','number':34,'pitch':windowsf[10]['pitch'], 'nangle': windowsf[10]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},51 {'side':'f','number':44,'pitch':windowsf[11]['pitch'], 'nangle':windowsf[11]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},52 {'side':'r','number':11,'pitch':windowsr[0]['pitch'], 'nangle':windowsr[0]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},53 {'side':'r','number':21,'pitch':windowsr[1]['pitch'], 'nangle': windowsr[1]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},54 {'side':'r','number':12,'pitch':windowsr[2]['pitch'],'nangle':windowsr[2]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},55 {'side':'r','number':22,'pitch':windowsr[3]['pitch'],'nangle':windowsr[3]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},56 {'side':'r','number':31,'pitch':windowsr[4]['pitch'], 'nangle':windowsr[4]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},57 {'side':'r','number':41,'pitch':windowsr[5]['pitch'], 'nangle':windowsr[5]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},58 {'side':'r','number':32,'pitch':windowsr[6]['pitch'], 'nangle':windowsr[6]['nominal angle'] ,'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},59 {'side':'r','number':42,'pitch':windowsr[7]['pitch'], 'nangle':windowsr[7]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},60 {'side':'r','number':33,'pitch':windowsr[8]['pitch'], 'nangle':windowsr[8]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},61 {'side':'r','number':43,'pitch':windowsr[9]['pitch'], 'nangle':windowsr[9]['nominal angle'] ,'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},62 {'side':'r','number':34,'pitch':windowsr[10]['pitch'], 'nangle': windowsr[10]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0},63 {'side':'r','number':44,'pitch':windowsr[11]['pitch'], 'nangle':windowsr[1]['nominal angle'],'pmean':0.0,'pmed':0.0,'pvar':0.0,'amean':0.0,'amed':0.0,'avar':0.0}]64 65 #frontdir='/Users/wheatley/Documents/Solar/MiSolFA/prototypes/mw469sub2737_2017_06_01'66 #reardir='/Users/wheatley/Documents/Solar/MiSolFA/prototypes/mw469sub2765_2017_06_02'67 os.chdir(front_dir)68 statfiles=glob.glob('*stats*'+str(mag)+'.p')69 #statfiles=glob.glob('*stats.p')70 for sf in statfiles:71 win=sf[3:5]72 idx=[i for i in range(0,12) if windows[i]['number']==int(win)][0]73 sdict=pickle.load(open(sf,'rb'))74 if 'width' in sf:75 windows[idx]['pmean']=sdict['mean']76 windows[idx]['pmed']=sdict['median']77 windows[idx]['pvar']=sdict['stddev']78 else:79 windows[idx]['amean']=sdict['mean']80 windows[idx]['amed']=sdict['median']81 windows[idx]['avar']=sdict['stddev']82 83 os.chdir(rear_dir)84 statfiles=glob.glob('*stats*'+str(mag)+'.p')85 #statfiles=glob.glob('*stats.p')86 for sf in statfiles:87 win=sf[3:5]88 idx=[i for i in range(12,24) if windows[i]['number']==int(win)][0]89 sdict=pickle.load(open(sf,'rb'))90 if 'width' in sf:91 windows[idx]['pmean']=sdict['mean']92 windows[idx]['pmed']=sdict['median']93 windows[idx]['pvar']=sdict['stddev']94 else:95 windows[idx]['amean']=sdict['mean']96 windows[idx]['amed']=sdict['median']97 windows[idx]['avar']=sdict['stddev']98 os.chdir('../')99 pickle.dump(windows,open('windows'+str(mag)+'.p','wb'))100 return windows101def repickle():102 frontdir='/Users/wheatley/Documents/Solar/MiSolFA/prototypes/mw469sub2737_2017_06_01'103 reardir='/Users/wheatley/Documents/Solar/MiSolFA/prototypes/mw469sub2765_2017_06_02'104 os.chdir(frontdir)105 statfiles=glob.glob('*stats.p')106 for sf in statfiles:107 sdict=pickle.load(open(sf,'rb'))108 data=sdict['data']109 stats={'mean':sdict['mean'],'median':sdict['median'],'stddev':sdict['stddev']}110 dname=sf[:-7]+'data.p'111 pickle.dump(data,open(dname,'wb'))112 pickle.dump(stats,open(sf,'wb'))113 114 os.chdir(reardir)115 statfiles=glob.glob('*stats.p')116 for sf in statfiles:117 sdict=pickle.load(open(sf,'rb'))118 data=sdict['data']119 stats={'mean':sdict['mean'],'median':sdict['median'],'stddev':sdict['stddev']}120 dname=sf[:-7]+'data.p'121 pickle.dump(data,open(dname,'wb'))122 pickle.dump(stats,open(sf,'wb'))123 os.chdir('../')124def plot_params(window,title1='Front Assembly',title2='Rear Assembly',ptype=False):125 error=np.zeros(12)+1.995126 #front window - pitch vs. expected values127 wnums=[window[i]['number'] for i in range(0,12)]128 nomsa=[window[i]['nangle'] for i in range(0,12)]129 pmeans=[window[i]['pmean'] for i in range(0,12)]130 print pmeans131 perrs=[window[i]['pvar'] for i in range(0,12)]132 noms=[]133 for i in range(0,12):134 noms.append(window[i]['pitch'])135 x=np.linspace(1,12,12)136 fig,ax=plt.subplots()137 ax.errorbar(x, np.array(pmeans)-np.array(noms), yerr=np.array(perrs),138 fmt='o', ecolor='g', capthick=2)139 #pl.plot(x, y, 'k', color='#CC4F1B')140 #ax.fill_between(x,-error, error,alpha=0.5, facecolor='#FF9848')141 ax.set_xticks(x)142 ax.set_xticklabels(wnums)143 ax.set_title(title1)144 ax.set_xlabel('Window Number')145 ax.set_xlim([0,13])146 ax.set_ylim([-2,2])147 ax.set_ylabel('Mean Pitch - Nominal Pitch, $\mu$m')148 fig.show()149 #return noms150 151 #front window - angle vs. expected values152 #wnums=[window[i]['number'] for i in range(0,12)]153 ameds=[np.abs(window[i]['amean']) for i in range(0,12)]154 aerrs=[window[i]['avar'] for i in range(0,12)]155 noms=[window[i]['nangle'] for i in range(0,12)]156 x=np.linspace(1,12,12)157 fig,ax=plt.subplots()158 ax.errorbar(x, ameds, yerr=aerrs,159 fmt='o', ecolor='g', capthick=2,label='Mean Value')160 ax.scatter(x,np.abs(np.array(noms)),color='r',marker='v',s=40, label='Nominal Value')161 #pl.plot(x, y, 'k', color='#CC4F1B')162 #ax.fill_between(x,noms-error, noms+error,alpha=0.5, facecolor='#FF9848')163 #ax.set_xtickinterval(x[:-1])164 ax.set_xticks(x)165 ax.set_xticklabels(wnums)166 ax.set_title(title1)167 ax.set_xlabel('Window Number')168 ax.set_xlim([0,13])169 ax.set_ylim([44.25,45.75])170 ax.set_ylabel('Absolute Value of Slat Orientation in degrees')171 ax.legend()172 fig.show()173 174 #rear window - pitch vs. expected values175 wnums=[window[i]['number'] for i in range(12,24)]176 if ptype: #shuffle the rear windows to correspond to the correct numbers177 real21=window[13]178 print real21['amean']179 real11=window[12]180 print real11['amean'] 181 real22=window[14]182 real12=window[15]183 real41=window[16]184 real31=window[17]185 real42=window[18]186 real32=window[19]187 real43=window[20]188 real33=window[21]189 real44=window[22]190 real34=window[23]191 window[12]['number']=21192 window[12]['nangle']=-44.72509193 window[13]['number']=11194 window[13]['nangle']=45.27757195 window[14]['number']=22196 window[14]['nangle']=44.93102197 window[15]['number']=12198 window[15]['nangle']=-45.06914199 window[16]['number']=41200 window[16]['nangle']=-45.13845 201 window[17]['number']=31202 window[17]['nangle']=44.86222203 window[18]['number']=42204 window[18]['nangle']=45.0553205 window[19]['number']=32206 window[19]['nangle']=-44.94481207 window[20]['number']=43208 window[20]['nangle']=-44.90807209 window[21]['number']=33210 window[21]['nangle']=45.09223211 window[22]['number']=44212 window[22]['nangle']= 44.954 213 window[23]['number']=34214 window[23]['nangle']=-45.04608215 nwins=[window[0],window[1],window[2],window[3],window[4],window[5],window[6],window[7],window[8],window[9],window[10],window[11],window[13],window[12],window[15],window[14],window[17],window[16],window[19],window[18],window[21],window[20],window[23],window[22]]216 window=nwins217 nomsa=[window[i]['nangle'] for i in range(12,24)] 218 pmeans=[window[i]['pmean'] for i in range(12,24)]219 perrs=[window[i]['pvar'] for i in range(12,24)]220 noms=[]221 for i in range(0,12):222 noms.append(window[i]['pitch'])223 x=np.linspace(1,12,12)224 fig,ax=plt.subplots()225 ax.errorbar(x, np.array(pmeans)-np.array(noms), yerr=np.array(perrs),226 fmt='o', ecolor='g', capthick=2)227 #pl.plot(x, y, 'k', color='#CC4F1B')228 ax.fill_between(x,-error, error,alpha=0.5, facecolor='#FF9848')229 #ax.set_xtickinterval(x[:-1])230 ax.set_xticks(x)231 ax.set_xticklabels(wnums)232 ax.set_title(title2)233 ax.set_xlabel('Window Number')234 ax.set_xlim([0,13])235 ax.set_ylim([-15,15])236 ax.set_ylabel('Mean Width - Nominal Width, $\mu$m')237 fig.show()238 #return noms239 240 #rear window - angle vs. expected values241 #wnums=[window[i]['number'] for i in range(0,12)]242 ameds=[np.abs(window[i]['amean']) for i in range(12,24)]243 aerrs=[window[i]['avar'] for i in range(12,24)]244 noms=[window[i]['nangle'] for i in range(12,24)]245 x=np.linspace(1,12,12)246 fig,ax=plt.subplots()247 ax.errorbar(x, ameds, yerr=aerrs,248 fmt='o', ecolor='g', capthick=2,label='Mean Value')249 ax.scatter(x,np.abs(np.array(noms)),color='r',marker='v',s=40,label='Nominal Value')250 #pl.plot(x, y, 'k', color='#CC4F1B')251 #ax.fill_between(x,noms-error, noms+error,alpha=0.5, facecolor='#FF9848')252 #ax.set_xtickinterval(x[:-1])253 ax.set_xticks(x)254 ax.set_xticklabels(wnums)255 ax.set_title(title2)256 ax.set_xlabel('(Rear) Window Number')257 ax.set_xlim([0,13])258 ax.set_ylim([44.25,45.75])# ax.set_ylim([44.25,46.75])259 ax.set_ylabel('Absolute Value of Slat Orientation in degrees')260 #ax.legend()261 fig.show()262 return window263def rv(value):264 return str(np.round([value],decimals=4)[0])265def dict2tex(window,filename=False):266 front=window[:12]267 rear=window[12:]268 fwlines,falines,rwlines,ralines=[],[],[],[]269 window_numbers=['11','21','12','22','31','41','32','42','33','43','34','44']270 for i,j,win in zip(front,rear,window_numbers):271 fwline=win+' & & '+rv(i['pmean'])+' & '+rv(i['pmed'])+' & '+rv(i['pvar'])+' & '272 faline=rv(i['amean'])+' & '+rv(i['amed'])+' & '+rv(i['avar'])+' & '273 rwline=rv(j['pmean'])+' & '+rv(j['pmed'])+' & '+rv(j['pvar'])+' & '274 raline=rv(j['amean'])+' & '+rv(j['amed'])+' & '+rv(j['avar'])+' \\'275 fwlines.append(fwline)276 falines.append(faline)277 rwlines.append(rwline)278 ralines.append(raline)279 280 lines=[fwlines[i]+falines[i]+rwlines[i]+ralines[i] for i in range(0,len(fwlines))]281 os.chdir('../')282 if not filename:283 filename='results_table.txt'284 with open(filename,'wb') as f:285 f.write('\n'.join(lines))...
script.py
Source:script.py
1import concurrent.futures2import sys3import argparse4import requests5import re6from colorama import Fore, Style7import time8# arguments9parser_arg_menu = argparse.ArgumentParser(prog='tool', formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=40)10)11parser_arg_menu.add_argument(12"-e" , "--endpoints" , help="File contain subdomains Ex: endpoints.txt",13metavar=""14)15parser_arg_menu.add_argument(16"-o", "--output" ,help="Output results in file", 17metavar=""18)19arg_menu = parser_arg_menu.parse_args()20endpoints_file = arg_menu.endpoints21output_file = arg_menu.output22# Reading givien input file and add =FUZZ then output it.23def readFile(filePath, output):24 with open(filePath, 'r') as file:25 for line in file:26 if '=' in line:27 patern = re.sub(r'=[a-zA-Z0-9%\-_.+:/]{0,}', '=FUZZ', line)28 print(patern, file=open(output, "a"))29 else:30 pass31# Sorting and delete duplicated lines32def sorting(output):33 with open(output) as resultx:34 uniqlines = set(resultx.readlines())35 delemptylines = filter(lambda x: not x.isspace(), uniqlines)36 with open(output, 'w') as final_file:37 final_file.writelines(set(delemptylines))38# Threading39def Thread(vuln):40 myList = open(output_file).readlines()41 with concurrent.futures.ThreadPoolExecutor() as executor:42 futures = []43 for url in myList:44 futures.append(executor.submit(vuln, url))45 for future in concurrent.futures.as_completed(futures):46 #print(future.result())47 pass48def testSQLI(url, timeout=10):49 r1 = requests.get(url, timeout)50 re1 = (len(r1.text))51 x = url.replace("FUZZ", "'")52 r2 = requests.get(x)53 re2 = (len(r2.text))54 if re2 < re1:55 print(Fore.GREEN + '[*] Vulnerable to SQLI => ' + Fore.YELLOW +url, end='')56 else:57 pass58def testXSS(url, timeout=10):59 x = url.replace('FUZZ', ">bat\"man/<'")60 r = requests.get(x, timeout)61 if ">bat\"man/<'" in r.text:62 print(Fore.GREEN + '[*] Vulnerable to XSS => ' + Fore.YELLOW +url, end='')63 else:64 pass65def testLFI(url, timeout=10):66 linux = url.replace('FUZZ', '../../../../../../../../../../../../../../../../../../../proc/version')67 linuxR = requests.get(linux, timeout)68 if "gcc" in linuxR.text:69 print(Fore.GREEN + '[*] Vulnerable to LFI (Linux) => ' + Fore.YELLOW +url, end='')70 else:71 pass72 x = url73 windows = x.replace('FUZZ', "C:/Windows/win.ini")74 try:75 windowsR = requests.get(windows)76 if "[Mail]" in windowsR.text:77 print(Fore.GREEN + '[*] Vulnerable to LFI (Windows) => ' + Fore.YELLOW +url, end='')78 79 except Exception as error:80 print(error)81if __name__=='__main__':82 try:83 if arg_menu.endpoints:84 t1 = time.perf_counter()85 86 print(Style.BRIGHT + Fore.RED + '''87 ___ ______ _____88 / |/_ __/ /__ /89 / /| | / / / / 90 / ___ |/ / / / 91 /_/ |_/_/_____ /_/ 92 /_____/93''')94 print(Fore.YELLOW + ''' CODED BY : A.Tarek95''')96 #Running Functions97 readFile(endpoints_file, output_file)98 sorting(output_file)99 print(Fore.CYAN + "[#]Testing LFI[#]")100 Thread(testLFI)101 print(Fore.CYAN + "[#]Testing SQLI[#]")102 Thread(testSQLI)103 print(Fore.CYAN + "[#]Testing XSS[#]")104 Thread(testXSS)105 t2 = time.perf_counter() - t1106 print(f'Total time taken: {t2:0.2f} seconds')107 else:108 print(Fore.YELLOW + '[*] Usage: python3 script.py -e endpoints.txt -o output.txt')109 except:...
one.py
Source:one.py
1print('''Ð¯ÐºÑ ÐС ви викоÑиÑÑовÑÑÑе?21 - windowsr32 - windowsXP43 - windowsVista''')5os = input('ÐведÑÑÑ ÑиÑло, Ñке вÑдповÑÐ´Ð°Ñ Ð²ÑдповÑдÑ: ')6os = os.rstrip('\r')7if os == '1' :8 print('Ðи вибÑали Windows 7 ')9elif os == '2':10 print('Ðи вибÑали Windows XP ')11 12elif os == '3':13 print('Ðи вибÑали Windows Vista ')14else:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!