def up(): gpio.output(16,1) for i in range(0,8): gpio.output(12,1) s(t) gpio.output(12,0) s(t) gpio.output(16,0)
def down(): gpio.output(16,0) for i in range(0,8): gpio.output(12,1) s(t) gpio.output(12,0) s(t) gpio.output(16,0)
def down(x): gpio.output(16, 1) for n in range(0, x): for i in range(0, 8): gpio.output(12, 1) s(t) gpio.output(12, 0) s(t) gpio.output(16, 0)
def singleSnap(tweet,ti): #Single picture capture on() c = picamera.PiCamera() c.resolution = (1600,900) s(1) c.capture(ti+'.png') c.close() scale.scaleB(ti+'.png') off()
def timeLapse(tweet,ti): fonT = imgF.truetype('/usr/share/fonts/truetype/freefont/FreeSansBold.ttf',60) frequency = 1 duration = 1 #Looking for the requested duration if (u'duration' in tweet): indexD = tweet.index('duration')+9 duration = u'' while tweet[indexD] != u' ': duration = duration+tweet[indexD] indexD = indexD+1 if indexD > len(tweet)-1: break duration = int(duration) #Looking for the frequency if (u'frequency' in tweet): indexF = tweet.index('frequency')+10 frequency = u'' while tweet[indexF] != u' ': # and indexF <len(tweet) ? frequency = frequency+tweet[indexF] indexF = indexF+1 if indexF > len(tweet)-1: break frequency = int(frequency) nImg = int(frequency*duration) on() #Timelapse loop for ix in range(0,nImg): c = picamera.PiCamera() c.resolution = (1600,900) s(1) c.capture(str(ix)+'.png') c.close() s(60/frequency) off() tempIm = img.new('RGB',(800,900)) for k in range(0,nImg): img2open = img.open(str(k)+'.png') imgD.Draw(img2open).text((1530,830),str(k+1),font=fonT,fill=(0,0,0,255)) img2open.save(str(k)+'.png') uploadFlickr(str(k)+'.png','Image '+str(k+1)+' of timelapse initiated on '+ti) image1 = img.open('0.png').resize((800,450)) image2 = img.open(str(nImg-1)+'.png').resize((800,450)) tempIm.paste(image1,(0,0)) tempIm.paste(image2,(0,450)) tempIm.save(ti+'.png')
def main(): x = 0 calVal = calibration() while True: lcd.on_lcd('cute',2) potVal = float(pot.read()) stdAcc = [] while potVal < (calVal+calVal*0.05): potVal = float(pot.read()) stdAcc.append(float(galv.read())) s(0.001) if len(stdAcc) == 8000: stdAcc = [] if (stDev(stdAcc) < 70) and (temp_check() < 35): sendTweet('I\'m stressed #beconhug '+str(locT().tm_hour-5)+':'+str(locT().tm_min)) s(1) go()
def post(self, PAGE_RE): text = self.request.get('content') self.PAGE_RE = PAGE_RE console(self.PAGE_RE) console(text) if text: w = Wiki.submit(self.PAGE_RE, text) w.put() console("Worked" + w.text) s(1) self.redirect(PAGE_RE) else: console("Didnt work") self.redirect('/_edit' + PAGE_RE)
def newmath(): from time import sleep as s print 'New Math!', s(.5) print ' New-', s(.15) print 'hoo-', s(.15) print 'hoo', s(.15) print 'math' #print '''You can't take three from two,
def on_data(self,data): #Convert the JSon object to unicode try: y = json.loads(data) name = y['user']['name'] at = y['user']['screen_name'] tweet = y['text'] loc = y['user']['location'] ti = y['created_at'] print at,' ',name,' ',tweet,' ',loc,' ',ti print if (u'@becon_hug' in tweet) or (u'@BeCon_Hug' in tweet) or (u'@Becon_Hug' in tweet): if (u'beconhug' in tweet) or (u'BeconHug' in tweet): #or (u'#beconhug' in tweet): lcd.on_lcd('@'+str(at),1) sol.write(1) pump.write(1) s(3) pump.write(0) s(5) sol.write(0) s(4) return False except KeyError: pass
def focusImg(tweet,ti): if (u'further' in tweet): indexUp = tweet.index('further')+8 nUp = u'' if indexUp < len(tweet): try: while tweet[indexUp] != u' ': nUp = nUp+tweet[indexUp] indexUp = indexUp+1 if indexUp > len(tweet)-1: break except IndexError,TypeError: nUp = 1 if nUp == u'': nUp = 1 else: nUp = int(nUp) up(nUp) on() c = picamera.PiCamera() s(1) c.capture(ti+'.png') c.close() off()
while True: try: msg = (input("enter the message:\n")).lower() key = int(input("enter the key:")) % 26 for i in msg: if i[0:1] == (" ") and len(i) >= 1: encrypt += i else: encrypt += (alphabet[(key + alphabet.index(i)) % 26]) print(encrypt) break except ValueError: print( "\nplease enter your message without any special charcters and key in only integer" ) s(3) elif act == 'd': while True: try: msg1 = (input("enter the message:\n")).lower() key1 = int(input("enter the key:")) % 26 for i in msg1: if i[0:1] == (" ") and len(i) >= 1: decrypt += i else: decrypt += (alphabet[(alphabet.index(i) - key1) % 26]) print(decrypt) break except ValueError: print(
terra = Label(tela, text=piso) terra['bg'] = 'green' terra['fg'] = 'green' terra.place(x=contPiso, y=437) contPiso += 16 tela = Tk() tela.geometry('448x456+150+150') tela.title('JogoQuadrado') tela['bg'] = 'black' while __name__ == "__main__": if lop1 == True: main() AtaqueZumbi() lop1 = False try: ZumbiMovimento() VerificarVidaEDano() tela.update() except: break s(0.026) try: tela.mainloop() except: pass
def load_anim(): c() print(co.m + 'Loading game.') s(.35) c() print(co.m + 'Loading game..') s(.35) c() print(co.m + 'Loading game...') s(.35) c() print(co.m + 'Loading game.') s(.35) c() print(co.m + 'Loading game..') s(.35) c() print(co.m + 'Loading game...') s(.35) c()
from time import sleep as s from random import randint jogo = {} ranking = {} print('Valores Sorteados:') for jogador in range(1, 5): s(0.5) random = randint(1, 6) print(f' O jogador {jogador} tirou {random}') jogo['jogador', jogador] = random print('Ranking dos jogadores:') # COMO FUNCIONA LAMBDA E ITEMGETTER? ranking = sorted(jogo.items(), key=lambda item: item[1], reverse=True) # key=lambda x: x[1] for k, v in enumerate(ranking): print(f'{k+1}º lugar: {v[0]} com {v[1]}') # O ex-dicionário "ranking" foi transformado em uma lista, # por isso, eu usei o "enumerate" que não funciona em dict # https://www.w3schools.com/python/python_lambda.asp # https://docs.python.org/3/library/operator.html # Comparar ex#91 e ex#91a # todo MUITO IMPORTANTE ENTENDER TODOS OS COMANDOS DA LINHA 12
import os from requests import get from time import sleep as s ##set host = '192.168.43.160' num = 1 speed = 16 rows, col = os.popen('stty size', 'r').read().split() deelay = int(col) / speed ## g = '' while str(num) != g: s(0.1) g = get('http://' + host + '/gt').text #print(g) s(delay) get('http://' + host + '/sw') os.system('sl')
temp = getIPs(files[x]) d1['e'] = temp t = [] t = list(d1['e']) masterIPs.append(t) toLogFile(t, str(files[x])) print(d1['e']) elif (x == 5): print("FILE: ", files[x], " and has ", getLinesFromFile(files[x])) temp = [] temp = getIPs(files[x]) d1['f'] = temp t = [] t = list(d1['f']) masterIPs.append(t) toLogFile(t, str(files[x])) print(d1['f']) s(1) x += 1 insertIntoOtherDB() ipcheck() ipCounter() #print(files) ########################################### # created by Samuel Schatz # # github: https://github.com/sschatz1997 # # email: [email protected] # ###########################################
percents = format_str.format(100 * (iteration / float(total))) filled_length = int(round(bar_length * iteration / float(total))) bar = '█' * filled_length + '-' * (bar_length - filled_length) sys.stdout.write('\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix)), if iteration == total: sys.stdout.write('\n') sys.stdout.flush() # ---------------------------------- CODE BEGINS HERE ---------------------------------- # LOGOS print("Blu's Game Centre v1.0") print("Aiyurn (C) 2016\n") s(1) # WARNING PROMPT print("Have you read the warning before? (Yes / No)") warning = input("> ") # WARNING PROMPT VARIABLES warning_yes = ["y", "ye", "yes"] warning_no = ["n", "no"] read_warning = 0 while read_warning == 0: # While the user hasn't seen the warning. warning = warning.lower() if warning in warning_yes: # If the user answered yes for reading the warning. print("Welcome back!") s(1) print()
def _set_ip_(self): print(Fore.RED + Style.BRIGHT + '[-]' + Fore.WHITE + ' Setup IP not complete...') print(Style.BRIGHT + Fore.RED + '[-]' + Fore.WHITE + ' Connection to IP not complete...') print('\n\n') s(3.6) "Sets up an IP to connect to a file" global IP for i in IP: print(Style.BRIGHT + Fore.GREEN + 'IP: ' + Fore.WHITE + i) assign = input('Assign files more than one IP?[y/n] ') if assign == 'y': self.assign = True d = [] how_many = input('How many IP connection >> ') if how_many == '1': raise Exception('Cannot do 1 connection, must be 2 or 3') if how_many == '2': for i in range(2): self.path = os.environ.get('HOME') os.system(f'clear && cd {self.path} && echo "\n" && ls') folder_name = input( '\nName of folder which contains the file: ') if '.gf' in folder_name: if os.path.exists(self.path + '/Con_Files' + '/' + folder_name): get_file = open( self.path + '/Con_Files' + '/' + folder_name, 'r').read() get_file = get_file.replace('\n', '') with open( self.path + '/Con_Files' + '/' + folder_name, 'w') as file: file.write(get_file) file.close() self.path = self.path + get_file d.append(self.path) else: print('Cannot find ' + folder_name + ' in ' + os.path.abspath('Con_Files')) else: if not len(d) > 1: if folder_name != '': self.path = self.path + '/' + folder_name os.system( f'cd {os.path.abspath(self.path)} && echo "\n" && ls' ) else: os.system('clear && cd && echo "\n" && ls') file_name = input(f'File {i+1}: ') if file_name == 'data.txt': _raise_error_(file_name) if file_name == 'data.jsn': _raise_error_(file_name) if file_name == 'complete_connection.json': _raise_error_(file_name) self.path = os.path.join(self.path, file_name) d.append(self.path) if not os.path.exists(os.path.abspath(d[0])): raise NotADirectoryError('No such directory ' + os.path.abspath(d[0])) if not os.path.exists(os.path.abspath(d[1])): raise NotADirectoryError('No such directory ' + os.path.abspath(d[1])) if os.path.exists(os.path.abspath(d[0])) and os.path.exists( os.path.abspath(d[1])): self.info.update({ 'ip_connectivity_info': { IP[0]: [os.path.abspath(d[0])], IP[1]: [os.path.abspath(d[1])] }, 'file_connectivity_info': { os.path.abspath(d[0]): [IP[0]], os.path.abspath(d[1]): [IP[1]] } }) elif how_many == '3': for i in range(3): self.path = os.environ.get('HOME') os.system(f'clear && cd {self.path} && echo "\n" && ls') folder_name = input( '\nName of folder which contains the file: ') if '.gf' in folder_name: if os.path.exists(self.path + '/Con_Files' + '/' + folder_name): op = open( self.path + '/Con_Files' + '/' + folder_name, 'r').read() op = op.replace('\n', '') with open( self.path + '/Con_Files' + '/' + folder_name, 'w') as file: file.write(op) file.close() self.path = self.path + op d.append(self.path) else: print('Cannot find ' + folder_name + ' in ' + os.path.abspath('Con_Files')) else: if folder_name != '': self.path = self.path + '/' + folder_name os.system( f'cd {os.path.abspath(self.path)} && echo "\n" && ls' ) else: os.system('clear && cd && echo "\n" && ls') file_name = input(f'File {i+1}: ') if file_name == 'data.txt': _raise_error_(file_name) if file_name == 'data.json': _raise_error_(file_name) if file_name == 'complete_connection.json': _raise_error_(file_name) self.path = os.path.join(self.path, file_name) d.append(self.path) if not os.path.exists(os.path.abspath(d[0])): raise NotADirectoryError('No such directory ' + os.path.abspath(d[0])) if not os.path.exists(os.path.abspath(d[1])): raise NotADirectoryError('No such directory ' + os.path.abspath(d[1])) if not os.path.exists(os.path.abspath(d[2])): raise NotADirectoryError('No such directory ' + os.path.abspath(d[2])) if os.path.exists(os.path.abspath(d[0])) and os.path.exists( os.path.abspath(d[1])) and os.path.exists( os.path.abspath(d[2])): self.info.update({ 'ip_connectivity_info': { IP[0]: [os.path.abspath(d[0])], IP[1]: [os.path.abspath(d[1])], IP[2]: [os.path.abspath(d[2])] }, 'file_connectivity_info': { os.path.abspath(d[0]): [IP[0]], os.path.abspath(d[1]): [IP[1]], os.path.abspath(d[2]): [IP[2]] } }) if self.info['ip_connectivity_info'][IP[0]][0] == self.info[ 'ip_connectivity_info'][IP[1]][0]: CHECK(self.info, 1) err = True if self.info['ip_connectivity_info'][IP[0]][0] == self.info[ 'ip_connectivity_info'][IP[2]][0]: CHECK(self.info) err = True if self.info['ip_connectivity_info'][ IP[0]][0] == self.info['ip_connectivity_info'][ IP[1]][0] and self.info['ip_connectivity_info'][ IP[1]][0] == self.info['ip_connectivity_info'][ IP[2]][0]: del (self.info['ip_connectivity_info'][IP[1]]) del (self.info['ip_connectivity_info'][IP[2]]) with open('deleted_ip.txt', 'w') as deleted_ip: deleted_ip.write('DELETED ' + IP[1] + '\n' + 'DELETED ' + IP[2]) deleted_ip.close() err_msg = f'You assigned the path {os.path.abspath(d[0])} to more than 1 ip address, which returned this warning\n' + Style.BRIGHT + Fore.RED + self.info[ 'mutliple_ip_connection_with_file_error'][ 'warning'] + '\n' + Style.RESET_ALL with open('error_message', 'w') as file: file.write(err_msg) file.close() if err: self.info.update({ 'mutliple_ip_connection_with_file_error': { 'warning': f'the file {os.path.abspath(d[0])} is a primary source and cannot be shared among other ip addresses', 'err_message': 'user tried to connect one file to multiple other IP addresses', 'more_info': 'you can see the IP addresses you tried to assign in the file to in deleted_ip.txt' } }) else: raise Exception( 'There is a max of 3 IP connections available, cannot assign ' + how_many + ' connections') elif assign == 'n': self.assign = False else: raise Exception('Choice ' + assign + ' is not a valid choice') get_ip = input('Which Ip would you like to use? [1,2,3] ') # Getting the IP if get_ip == '1': ip = f'{IP[0]}' elif get_ip == '2': ip = f'{IP[1]}' elif get_ip == '3': ip = f'{IP[2]}' else: raise Exception('Choice ' + get_ip + ' is not a valid choice') if assign == 'n': self.info = {'ip_connectivity_info': {ip: []}} # This will be used for connections across the platform self.ip = str(ip)
def _append_connections_(self): "will append network information for file connections" get_data = json.loads(open('data.json', 'r').read()) con_data = json.loads(open('complete_connection.json', 'r').read()) if get_data['using']['ip'] == con_data['ip_connection_data']['IP']: os.system('clear') print( 'Connection has been established, IP ' + get_data['using']['ip'] + ' in use with file ' + get_data['using']['file'] + f'\nOld Info: {open("old_info.txt","r").read()}\nTRANSFERED INTO: old_info.txt' + '\n\nWARNING:\n' + open(get_data['using']['file'], 'r').read()) s(4.2) subprocess.call('clear', shell=True) if not 'ip_key' in get_data['using']: for i in range(len(IP)): if IP[i] in get_data['ip_connectivity_info']: get_key = input( '\nKey for IP ' + IP[i] + '[press enter if you want a default key] >> ') if get_key == '': get_key = default_keys[0] del (default_keys[0]) get_data['ip_connectivity_info'][IP[i]].append( {'ip_key': get_key}) for j in get_data['file_connectivity_info']: if j in get_data['ip_connectivity_info'][IP[i]]: get_data['file_connectivity_info'][j] = IP[i], { 'ip_key': get_key } #print(get_data['file_connectivity_info'][j]) IP_KEYS.update({IP[i]: get_key}) if len(get_data['ip_connectivity_info'][IP[i]]) == 1: print(IP[i] + ' connects to ' + get_data['ip_connectivity_info'][IP[i]][0]) else: print(IP[i] + ' connects to ' + str(get_data['ip_connectivity_info'][IP[i]])) if IP[i] == get_data['using']['ip']: get_data['using'].update({'ip_key': get_key}) else: if get_data['using']['file'] in get_data[ 'ip_connectivity_info'][IP[i]]: get_data['using'].update({'ip_key': get_key}) with open('data.json', 'w') as file: to_json = json.dumps(get_data, indent=2, sort_keys=False) file.write(to_json) file.close() # This will store the IP keys in complete_connection.json and will further be used # when a user uses his/her IP key to connect to another IP address to request, send, or pull # this will be used to append the IP address if it's in data.json l._gather_keys_(get_data)
def sugarbank(sugar, bank, chocolate, chocoxplode, cost): beforeState = deepcopy([sugar, bank, chocolate, chocoxplode, cost]) wowword = [ "INFINITY", "112409", "PYTHON", "AXOLOTL", "PUPPY", "WOLF", "I WANT CHOCOLATE", "PYTHONMASTER24" ] theword = rc(wowword) s(2) print(f'\n\nYour sugar balance is {sugar}') print(''' Welcome to the sugar bank! What would you like to do? Type CAT for deposit Type SNAKEFACE for withhdrawl Type HAMSTER to rob the bank (WARNING: If the bank is in debt you will pay the debt for the bank.) Type MANGO to light your sugar on fire Type GORILLA to give the bank your money Type RAVEN to trade some sugar for chocolate Type LADYBUG to play the lottery Type WOLF to make chocoxplode (exploding chocolate with enchaned flavor) Type BREAD to go buy bread Type BANK to see how much money the bank has Type LAND MONSTER to try to control the Land Monster. ''') choice = input("Please pick an option") if choice == 'CAT': choice = input("How many sugars do you want to deposit") choice = int(choice) print("You deposit {choice} sugars") sugar -= choice bank += choice elif choice == 'HAMSTER': print("You rob the bank") s(2) print("The bank gives you " + str(bank) + "sugars") s(2) print("You now have a huge amount of sugar") sugar += bank bank = 0 elif choice == 'MANGO': print("You light your sugar on fire") sugar = 0 print("You now have no sugar.") print("I hope you feel the pain of sugar poverty!\n") elif choice == 'GORILLA': bank += sugar sugar = 0 print( "You give all your sugar to the bank. The bank will remember your kindness." ) s(2) print( "But a gorilla hears you calling it so it rampages and nearly kills you. " ) s(2) print("But it kills you. You die. The end,.") s(5) print( "Just kidding! The bank remembers your kindness and gives the gorilla 100 sugar. It agrees to leave you alone. " ) bank -= 100 elif choice == 'LADYBUG': if sugar < cost: print("You can't afford the lottery!") else: winning = [] winning.append(r(1, 10)) winning.append(r(1, 10)) winning.append(r(1, 10)) lottery = [] print("You decide to play the lottery") print("The lottery costs {cost} sugar") sugar -= cost cost *= 1.4 for i in range(3): choice = input("Pick a number ") choice = int(choice) lottery.append(choice) print(f'The winning lottery numbers are:') for number in winning: print(number) if lottery in winning: print("You won the lottery!") sugar += 10 * number elif choice == 'BREAD': print("You go to the bread bank") url = open("bread.txt") html = url.read() print(html) elif choice == 'RAVEN': print("1 chocobar => 50 sugars (chocolate is better than sugar!)") chocolate = input("How many chocobars would you like?") elif choice == 'WOLF': print("10 chocolates + 100 sugars => chocoxplode") chocoxplode += int(input("How many chocoxplodes would you like?")) chocolate -= int(10 * int(chocoxplode)) sugar -= 100 * int(chocoxplode) elif choice == 'BANK': print(bank) elif choice == 'LAND MONSTER': x = r(0, 2) item = [ "a Lazer sword", "a newspaper", "an ocotopus you found", "the old man over there", "some sort of ancient relic", "a dinosaur bone" ] item = rc(item) print("You hit the Land Monster with " + item + ".") s(2) if x == 0: print("The Land Monster doesn't respond.") s(2) print("It swings at you. What do you do?") s(2) print('''You can: 1. Keep fighting 2. Run away 3. Throw a chocoxplode at it''') choice = input("CHOOSE 123.") if choice == 1: print( "You keep fighting. You lose. You are robbed of 1000 sugars." ) sugar -= 1000 elif choice == 2: print("You run away, but you lose a chocolate on the way.") chocolate -= 1 else: print("You threw a chocoxplode into the monster's mouth.") chocoxplode -= 1 s(2) print( "The Land Monster explodes. It has not died but you have defeated it. " ) s(2) choice = input('''You can: 1. Take it as a pet and know that you can play with item 2. Kill it''') if choice == 1: landmonsteractivate = True print( "Bonus! It gives you 50 chocolates every time you play again. But the sad thing is it gobbles up 500 sugars ever time it does that. " ) else: print("Turns out it's immortal.") s(2) print("It eats all your things.") sugar = 0 chocolate = 0 chocoxplode = 0 else: print("You defeated the Land Monster. Congrats!") s(2) print('''You can: 1. Kill it and gain 1,000,000 sugars 2. Keep it as a tamed pet that gobbles up 500 sugars per minute but gives you 50 chocobars every time you play again ''') s(2) choice = input("CHOOSE 12") if choice == 1: print("You killed the Land Monster!") sugar += 1000000 else: landmonsteractivate = True elif choice == theword: print( "Wow! You found the word! I'll give you 1,000,000,000 sugars, 1,000,000 chocolates, and 100,000 chocoxplodes just for guessing it!" ) sugar += 1000000000 chocolate += 1000000 chocoxplode += 100000 else: print("You take 100 sugars") sugar += 100 bank -= 100 print(f'\nYour sugar balance is {sugar}\n') print(f'\nYour chocolate balance is {chocolate}\n') print(f'\nYour chocoxplode balance is {chocoxplode}\n') s(2) if sugar < 0 or chocoxplode < 0 or chocolate < 0: print(f'\nYou have spent too much. I' 'll turn back time.\n') (sugar, bank, chocolate, chocoxplode, cost) = beforeState choice = input("Do you want to play again? y/n ") s(1) if choice == 'y': sugarintro(sugar, bank, chocolate, chocoxplode, cost) else: print("Not like you have much choice.") sugarintro(sugar, bank, chocolate, chocoxplode, cost)
from os import popen as p from shutil import rmtree as r from time import sleep as s opc = ['Defragmentação', 'Drivers', 'Arquivos Temporarios'] while True: try: print(f'1 {opc[0]}\n2 {opc[1]}\n3 {opc[2]}\n') resp = int(input('Digite uma opção(0 para encerrar o programa):')) if resp == 1: print('Opção um Digitada') s(1) print('Abrindo o Programa...\n') s(2) p('SmartDefragPortable.exe') elif resp == 2: print('Opção dois Digitada') s(1) print('Abrindo o Programa...\n') s(2) p('DriverEasyPortable.exe') elif resp == 3: print('Opção três Digitada') s(1) print('Excluindo Pasta...\n') s(2) r('C:\\Windows\\Temp', ignore_errors=True) elif resp == 0: print('Encerrando o Programa.') s(2)
time.sleep(8) print("hello") # In[13]: print("hi") sleep(4) print("hello") # In[14]: from time import sleep as s # In[15]: s(2) # In[16]: print("hi") sleep(4) print("hello") # In[17]: import time as t # In[18]: ruchika_jupyter.black()
def print_info(self): super().print_info() print('Turbine started?:', self._turbine_is_started) s(3)
def _set_ip_(self): print(Fore.RED + Style.BRIGHT + '[-]' + Fore.WHITE + ' Setup IP not complete...') print(Style.BRIGHT + Fore.RED + '[-]' + Fore.WHITE + ' Connection to IP not complete...') print('\n\n') s(3.6) "Sets up an IP to connect to a file" global IP for i in IP: print(Style.BRIGHT + Fore.GREEN + 'IP: ' + Fore.WHITE + i) assign = input('Assign files more than one IP?[y/n] ') if assign == 'y': self.assign = True d = [] how_many = input('How many IP connection >> ') if how_many == '1': raise Exception('Cannot do 1 connection, must be 2 or 3') if how_many == '2': for i in range(2): self.path = os.environ.get('HOME') os.system(f'clear && cd {self.path} && echo "\n" && ls') folder_name = input( '\nName of folder which contains the file: ') if '.gf' in folder_name: if os.path.exists(self.path + '/Con_Files' + '/' + folder_name): get_file = open( self.path + '/Con_Files' + '/' + folder_name, 'r').read() self.path = self.path + get_file d.append(self.path) print(d) else: print('Cannot find ' + folder_name + ' in ' + os.path.abspath('Con_Files')) else: if not len(d) > 1: if folder_name != '': self.path = self.path + '/' + folder_name os.system( f'cd {os.path.abspath(self.path)} && echo "\n" && ls' ) else: os.system('clear && cd && echo "\n" && ls') file_name = input(f'File {i+1}: ') if file_name == 'data.txt': _raise_error_(file_name) if file_name == 'data.jsn': _raise_error_(file_name) if file_name == 'complete_connection.json': _raise_error_(file_name) self.path = os.path.join(self.path, file_name) d.append(self.path) if not os.path.exists(os.path.abspath(d[0])): raise NotADirectoryError('No such directory ' + os.path.abspath(d[0])) if not os.path.exists(os.path.abspath(d[1])): raise NotADirectoryError('No such directory ' + os.path.abspath(d[1])) if os.path.exists(os.path.abspath(d[0])) and os.path.exists( os.path.abspath(d[1])): self.info.update({ 'ip_connectivity_info': { IP[0]: [os.path.abspath(d[0])], IP[1]: [os.path.abspath(d[1])] }, 'file_connectivity_info': { os.path.abspath(d[0]): [IP[0]], os.path.abspath(d[1]): [IP[1]] } }) elif how_many == '3': for i in range(3): self.path = os.environ.get('HOME') os.system(f'clear && cd {self.path} && echo "\n" && ls') folder_name = input( '\nName of folder which contains the file: ') if '.gf' in folder_name: if os.path.exists(self.path + '/Con_Files' + '/' + folder_name): op = open( self.path + '/Con_Files' + '/' + folder_name, 'r').read() self.path = self.path + op d.append(self.path) print('Cannot find ' + folder_name + ' in ' + os.path.abspath('Con_Files')) else: if folder_name != '': self.path = self.path + '/' + folder_name os.system( f'cd {os.path.abspath(self.path)} && echo "\n" && ls' ) else: os.system('clear && cd && echo "\n" && ls') file_name = input(f'File {i+1}: ') if file_name == 'data.txt': _raise_error_(file_name) if file_name == 'data.json': _raise_error_(file_name) if file_name == 'complete_connection.json': _raise_error_(file_name) self.path = os.path.join(self.path, file_name) d.append(self.path) if not os.path.exists(os.path.abspath(d[0])): raise NotADirectoryError('No such directory ' + os.path.abspath(d[0])) if not os.path.exists(os.path.abspath(d[1])): raise NotADirectoryError('No such directory ' + os.path.abspath(d[1])) if not os.path.exists(os.path.abspath(d[2])): raise NotADirectoryError('No such directory ' + os.path.abspath(d[2])) if os.path.exists(os.path.abspath(d[0])) and os.path.exists( os.path.abspath(d[1])) and os.path.exists( os.path.abspath(d[2])): self.info.update({ 'ip_connectivity_info': { IP[0]: [os.path.abspath(d[0])], IP[1]: [os.path.abspath(d[1])], IP[2]: [os.path.abspath(d[2])] }, 'file_connectivity_info': { os.path.abspath(d[0]): [IP[0]], os.path.abspath(d[1]): [IP[1]], os.path.abspath(d[2]): [IP[2]] } }) else: raise Exception( 'There is a max of 3 IP connections available, cannot assign ' + how_many + ' connections') elif assign == 'n': self.assign = False else: raise Exception('Choice ' + assign + ' is not a valid choice') get_ip = input('Which Ip would you like to use? [1,2,3] ') # Getting the IP if get_ip == '1': ip = f'{IP[0]}' elif get_ip == '2': ip = f'{IP[1]}' elif get_ip == '3': ip = f'{IP[2]}' else: raise Exception('Choice ' + get_ip + ' is not a valid choice') if assign == 'n': self.info = {'ip_connectivity_info': {ip: []}} # This will be used for connections across the platform self.ip = str(ip)
from pyautogui import pixelMatchesColor as p from pyautogui import click as c from time import sleep as s while True: c(157, 700) s(0.2) while p(378, 460, (145, 138, 131)) == True: continue s(0.3) if p(416, 552, (161, 38, 28)) == p(415, 601, (164, 33, 27)) == True: break else: c(157, 789) s(0.1)
def save_anim(): c() print(co.m + 'Saving game.') s(.35) c() print(co.m + 'Saving game..') s(.35) c() print(co.m + 'Saving game...') s(.35) c() print(co.m + 'Saving game.') s(.35) c() print(co.m + 'Saving game..') s(.35) c() print(co.m + 'Saving game...') s(.35) c()
# Introduction - Variables game_choice = "" menu_time = 0 # TODO Fix up some menutime issues give_name = "" asked_name = 0 # Start - Game Choice input options game_arithmetic = ["1", "a", "arithmetic"] game_numguess = ["2", "n", "number guess"] game_cyoa = ["3", "c", "cyoa", "choose your own adventure"] # --------------- CODE BEGINS HERE --------------- print("Blu's Game Centre v1.0") print("Aiyurn (C) 2016\n") s(1) print("-------------------------------- WARNING --------------------------------\n" "Tailstar told me to remind you beforehand to not spam the enter button!\n" "He says that it will not only ruin the experience, but also screw up\n" "the code as you are inputting 'enter' for the upcoming inputs!\n" "-------------------------------------------------------------------------\n" "\n" "Now with that out of the way, let's play!") items = list(range(0, 110)) i = 0 l = len(items) # Initial call to print 0% progress progressbar(i, l, prefix='Loading:', suffix='Complete', barlength=50) for item in items: # Do stuff...
from time import sleep as s for i in range(20): print('#' * 20, flush=False) s(0.1) input()
try: while tweet[indexDn] != u' ': nDn = nDn+tweet[indexDn] indexDn = indexDn+1 if indexDn > len(tweet)-1: break except IndexError,TypeError: nDn = 1 if nDn == u'': nDn = 1 else: nDn = int(nDn) down(nDn) c = picamera.PiCamera() s(1) c.capture(ti+'.png') c.close() off() if (u'dofocus' in tweet): fonT = imgF.truetype('/usr/share/fonts/truetype/freefont/FreeSansBold.ttf',30) imgArray = [] indexF = tweet.index('dofocus')+8 nFocus = u'' if indexF < len(tweet): try: while tweet[indexF] != u' ': nFocus = nFocus+tweet[indexF]
def death(): print(c.clear) print(c.r + deathscreen) s(5) continueq()
def go(): x = 0 print 'Live!' lcd.on_lcd('cute',4) x =Stream(auth,X()).filter(track =['beconhug']) s(10)
from projetinhos.ex115.interface import * # anotar isto: Para importar tudo from projetinhos.ex115.arquivo import * from time import sleep as s cadastros = 'cadastros.txt' if not arquivoexiste(cadastros): criararquivo(cadastros) while True: opcao = menu([ 'Ver pessoas cadastradas', 'Cadastrar nova pessoa', 'Sair do Sistema' ]) s(0.8) if opcao == 1: titulo('PESSOAS CADASTRADAS') lerarquivo(cadastros) if opcao == 2: titulo('NOVO CADASTRO') nome = str(input('Nome: ')) idade = leiaint('Idade: ') cadastrar(cadastros, nome, idade) if opcao == 3: exit(titulo('Saindo do sistema... Até logo!'))