def total_control(): while True: print('请输入字符,按回车结束,以执行您想要的操作\n' '输入 “###”:初始化账本。注意,此操作将会使您已有的账本丢失,请谨慎使用这一操作\n' '输入 “1”:记录您的现金收支\n' '输入 “2”:记录他人对你的欠账或清偿账款\n' '输入 “3”:清点账本,即清点所有原始记录,汇总出收支情况和债权情况\n' '输入 “4”:查询功能,可按月查询收支情况,或者按债务人姓名查询欠账情况\n' '输入 “q":退出程序') choice_1 = input('请输入:') if choice_1 == '###': tools.initialize_ledger() elif choice_1 == '1': executor, monthly_income = tools.get_data_from_history(0) log_set = tools.input_event(0, executor) tools.deal_with_new_log(0, log_set, executor, monthly_income) elif choice_1 == '2': executor, monthly_income, debt_data = tools.get_data_from_history( 1) log_set = tools.input_event(1, executor, debtor_dict=debt_data) tools.deal_with_new_log(1, log_set, executor, monthly_income, debtor_dict=debt_data) elif choice_1 == '3': tools.form_a_whole_summary() elif choice_1 == '4': tools.check() elif choice_1 == 'q': break else: print('错误!请输入有效的字符') continue
def compile(self) -> (MessageType, str): content_lines = self.content.split('\n') self.bin.append(get_hex(load_zero_instruction)) line = 1 for content_line in content_lines: content_line_raw_instruction = content_line.split(' ') log.info(content_line_raw_instruction) if content_line_raw_instruction[0] == '': continue elif len(content_line_raw_instruction) < 4: log.error("Error: instruction over/under 4 parts line:", line) content_line_instruction_opcode = get_opcode( content_line_raw_instruction[0]) content_line_instruction_arg1 = content_line_raw_instruction[1] content_line_instruction_arg2 = content_line_raw_instruction[2] content_line_instruction_arg3 = content_line_raw_instruction[3] temp_instruction = Instruction(content_line_instruction_opcode, content_line_instruction_arg1, content_line_instruction_arg2, content_line_instruction_arg3, False) message_type, message = check(temp_instruction) if message_type == MessageType.InstructionError: log.error("Error:", message, "Line", line) exit(4) elif message_type == MessageType.InstructionWarning: log.warning("Warning:", message, "Line:", line) else: log.info("Done Line:", line) self.bin.append(get_hex(temp_instruction)) line = line + 1
async def requirements(self, ctx, args): if not ctx.message.author.guild_permissions.administrator: embedVar = tools.embed("You must be an admin!", "You must have the administrator role to use this command.") await ctx.send(embed=embedVar) return if not args: embedVar = tools.embed("Please enter a valid arguement", "You have not entered any arguements.") await ctx.send(embed=embedVar) return False if not tools.check(ctx.guild.id): embedVar = tools.embed("You have not set any alarms!", "Please type ``a!help`` for help on how to create one.") await ctx.send(embed=embedVar) return False args = " ".join(args) for date in sorted(db[str(ctx.guild.id)].items()): if date[0] == "channel": continue print(date[0]) if args == date[0]: del db[str(ctx.guild.id)][date[0]] embedVar = tools.embed("Successfully deleted alarm", "Alarm ``" + date[1]["name"] + "`` has been successfully deleted.") await ctx.send(embed=embedVar) return False embedVar = tools.embed("Could not find alarm", "Alarm ``" + args + "`` does not exist.") await ctx.send(embed=embedVar) return False
async def cooldown(self, guild): tasking.append(guild) await self.client.wait_until_ready() while True: if not tools.check(guild): break for date in sorted(db[guild].items()): if date[0] == "channel": continue date = date[1] tz = timezone(timeZones[date["timezone"]]) day = datetime.now(tz) day = day.strftime("%A") if not day in date["disdays"]: if datetime.now(timezone( timeZones[date["timezone"]])).strftime( "%-I:%M%p") == date["time"] + date["apm"]: embedVar = tools.embed( "Alarm", "<@&" + str(date["role"]) + "> " + date["name"]) channel = self.client.get_channel(db[guild]["channel"]) await channel.send(embed=embedVar) mention = await channel.send("<@&" + str(date["role"]) + ">") await mention.delete() await asyncio.sleep((60 - datetime.utcnow().second) + 3)
def __init__(self,shape=None, opt=None): super().__init__(shape=shape,trainable=False,with_param=False) if type(shape)!=tuple and type(shape)!=int : log.warning('pool.stride shape should be tuple/int not {}. Also make sure len(shape)= dim(input)'.format(shape)) if type(shape) in {list,tuple} and len(shape) > 1: self.command = '[::'+ reduce(lambda a,b: str(a)+',::'+str(b),self.shape) +']' if type(shape)==int or tl.check('int(shape)'): self.shape = int(shape) self.command = '[::self.shape]'
async def requirements(self, ctx, *args): try: db[str(ctx.guild.id)] except: embedVar = tools.embed( "You have not set any alarms!", "Please type ``a!help`` to view command usage and how to set an alarm" ) await ctx.send(embed=embedVar) return if not ctx.message.author.guild_permissions.administrator: embedVar = tools.embed( "You must be an admin!", "You must have the administrator role to use this command.") await ctx.send(embed=embedVar) return if tools.check(ctx.guild.id) == False: embedVar = tools.embed( "You must set a channel before setting an alarm", "Please type ``a!setchannel [channel id]`` to set a channel for the bot to ping in." ) await ctx.send(embed=embedVar) return False if not args[1].lower().title() in disdays: embedVar = tools.embed("Please enter a valid day.", "Please enter a valid day of the week.") print("Not a valid day.") await ctx.send(embed=embedVar) return False if not args[0] in db[str(ctx.guild.id)]: embedVar = tools.embed("Not a valid Alarm ID.", "Please enter a valid alarm ID.") print("Not a valid Alarm ID.") await ctx.send(embed=embedVar) return False if not args[1].lower().title() in db[str( ctx.guild.id)][args[0]]["disdays"]: embedVar = tools.embed( "This day is not disabled for this alarm", "Please type ``a!help`` to view the command usage if you need help." ) print("Date not in DB.") await ctx.send(embed=embedVar) return False db[str(ctx.guild.id)][args[0]]["disdays"].remove(args[1].lower().title()) return True
async def setchannel(self, ctx, *args): if not ctx.message.author.guild_permissions.administrator: embedVar = tools.embed( "You must be an admin!", "You must have the administrator role to use this command.") await ctx.send(embed=embedVar) return id = ''.join(args) channel = None try: channel = self.client.get_channel(int(id)) except: embedVar = tools.embed("Invalid channel ID", "Please enter a valid channel ID.") await ctx.send(embed=embedVar) return if channel == None: embedVar = tools.embed("Invalid channel ID", "Please enter a valid channel ID.") await ctx.send(embed=embedVar) else: for channel in ctx.message.guild.channels: if channel == self.client.get_channel(int(id)): if tools.check(ctx.guild.id) == False: db[str(ctx.guild.id)] = {} db[str(ctx.guild.id)]["channel"] = int(id) embedVar = tools.embed( "Successfully set channel", "Your channel has been successfully set.") await ctx.send(embed=embedVar) return embedVar = tools.embed( "Invalid channel ID", "If you need help, please type ``a!help``.") await ctx.send(embed=embedVar)
def main(API): response = API.LastJson check(response, status='get API') t0 = time.clock() count_follower = 0 like_count = 0 reset_count = 0 count_error = 0 for i in range(0, 100): if i % 2 != 0: choice = 'popular' print "popular feed" API.getPopularFeed() #APPEL API json = API.LastJson check(json, status='popular feed') max = 100 else: choice = "hastags" print "hastag feed" API.getHashtagFeed('french') #APPEL API json = API.LastJson check(json, status='hastags feed') max = 100 for media in json['items'][0:max]: sleep(3) if choice == 'hastags': if media['like_count'] < 5: print 'Likes inf to 5' count_error += 1 else: print( str(media['like_count']) + ' like on this publication OK') print 'SUCESS after ' + str(count_error) + ' trial' count_error = 0 else: print 'no verification' print 'USER : https://instagram.com/' + str( media['user']['username']) like(API=API, media=media, like_count=like_count) print str( media['image_versions2']['candidates'][0]['url']) + ' liked !' API.getUserFeed(media['caption']['user_id']) #APPEL API feed = API.LastJson for media_feed in feed['items'][4:5]: like(API=API, media=media_feed, like_count=like_count) print str(media_feed['image_versions2']['candidates'][0] ['url']) + ' liked !' if reset_count == 10: API.follow(media['caption']['user_id']) print str(media['user']['username']) + ' followed!' count_follower += 1 reset_count = 0 print 'number: ' + str(count_follower) print 'Security break ON...' time_process = (time.clock() - t0) / 60. print '%.2f min since the beginning' % time_process print str(count_follower) + ' users followed' print str(like_count) + ' media liked' sleep(60 + random.randint(1, 10)) print '\nSecurity break OFF' print 'count: ' + str(reset_count) + '/7' reset_count += 1
async def requirements(self, ctx, args): if not ctx.message.author.guild_permissions.administrator: embedVar = tools.embed( "You must be an admin!", "You must have the administrator role to use this command.") await ctx.send(embed=embedVar) return if ctx.author.id == "771153822994530354" or ctx.author.id == "696790718743838793": print("hi") if ctx.author.bot: return False if len(args) < 5: print("Too little arguements") embedVar = tools.embed( "Please enter a valid amount of arguments", "Please check ``a!help`` to see the bot command usage.") await ctx.send(embed=embedVar) return False if args[0] and not ":" in args[0]: print("Time doesnt have colon") embedVar = tools.embed( "Please enter a valid time", "Please enter a valid time using the ``hour:format`` method.") await ctx.send(embed=embedVar) return False if args[0] and len(args[0].split(":")[1]) != 2: print("Minutes is too short") embedVar = tools.embed( "Please enter a valid time", "Please enter a valid arguement for the number of minutes.") await ctx.send(embed=embedVar) return False arg0int = args[0].replace(":", "") if arg0int.isdigit() and int(arg0int) > 1259 or arg0int.isdigit( ) and int(arg0int) < 100: print("Time too long / short") embedVar = tools.embed( "Please enter a valid time", "Please enter a valid time using standard clock format.") await ctx.send(embed=embedVar) return False if args[2] and not args[2].upper() in timeZones: print("Not a valid timezone") embedVar = tools.embed( "Please enter a compatible timezone", "To view the list of compatible timezones, please type ``a!timezones``." ) await ctx.send(embed=embedVar) return False if args[1] and args[1].upper() != "AM" and args[1].upper() != "PM": print("Not AM or PM") embedVar = tools.embed( "Please enter AM or PM as a valid argument", "Please enter a valid time using standard clock format.") await ctx.send(embed=embedVar) return False try: int(args[3]) except: embedVar = tools.embed( "Please enter a valid role ID", "Please enter a valid role id, and do not use mentions.") await ctx.send(embed=embedVar) return False if not discord.utils.get(ctx.message.guild.roles, id=int(args[3])): print("Invalid role") embedVar = tools.embed( "Please enter a valid role ID", "Please enter a valid role id, and do not use mentions.") await ctx.send(embed=embedVar) if tools.check(ctx.guild.id) == False: embedVar = tools.embed( "You must set a channel before setting an alarm", "Please type ``a!setchannel [channel id]`` to set a channel for the bot to ping in." ) await ctx.send(embed=embedVar) return False name = None for x in range(4, len(args)): if name == None: name = args[x] continue name = name + " " + args[x] for date in sorted(db[str(ctx.guild.id)].items()): if date[0] == "channel": continue #date = date[1] #if date["name"] == name: #embedVar = tools.embed("There is already an alarm with the same name!", "Please use ``a!deletealarm`` to delete the previous alarm before setting a new one.") #await ctx.send(embed=embedVar) #return False db[str(ctx.guild.id)][str(ctx.message.id)] = { "time": args[0], "apm": args[1], "timezone": args[2], "role": int(args[3]), "name": name, "disdays": [] } if not str(ctx.guild.id) in tasking: self.client.loop.create_task(cooldown(self, str(ctx.guild.id))) return str(ctx.message.id)
while(True): if len(past) > 20: del past[0] # Capture frame-by-frame ret, frame = cap.read() cv2.rectangle(frame,(100,100),(400,400),(255,0,0),3) image = frame[100:400,100:400] image = cv2.resize(image,consts.shape) input = np.reshape(image,consts.shape_for_nsamples(1))/255.0 prediction = tools.getPrediction(model.predict(input)[0]) past.append(prediction) if tools.check(past): if not prediction == None and not prediction == 'nothing': if prediction == 'space': sentence.append(' ') elif prediction == 'del': del sentence[len(sentence) - 1] else: sentence.append(prediction) past = [None] * 20 font = cv2.FONT_HERSHEY_SIMPLEX cv2.putText(frame,prediction,(600,100),font, 4,(0,0,255),2,cv2.LINE_AA) cv2.putText(frame,''.join(sentence),(100,600),font, 4,(0,0,255),2,cv2.LINE_AA) # Display the resulting frame cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'):
async def on_guild_remove(self, guild): if tools.check(guild.id): del db[str(guild.id)]
#!/usr/bin/python # -*- coding: UTF-8 -*- import tools # print(tools.__file__) tools.welcome() # 欢迎 n = 1 while n: password = tools.gen() # 生成密码列表 # print(password) # 打印密码 print('') guess = tools.guess() # 生成猜测列表 tools.check(password, guess) # 检测 n = int(input('play again? 1/0')) # 是否重新玩 else: print('Bye!') # 再见
try: os.mkdir(f'{root}/trash') except: pass cmd = [" "] tools.loadCache() while len(cmd): option = cmd.pop(0) try: if option=="new" : tools.new(cmd[0]) elif option=="open" : tools.open_dir(cmd[0]) elif option=="vim" : tools.vim(*cmd) elif option=="view" : tools.view(*cmd) elif option=="login": tools.login() elif option=="post" : tools.post(*cmd) elif option=="clear": tools.copyTemplates() elif option=="check": tools.check(True, *cmd) elif option=="run" : tools.check(False, *cmd) elif option=="save" : tools.saveSolution(*cmd) elif option=="rm" : tools.removeFile() elif option=="help" : print(help_string) except: print( f"ERR: {sys.exc_info()[0]} {sys.exc_info()[1]} "+ f"line: {sys.exc_info()[2].tb_lineno}") print("----------------------------------------------------") tools.saveCache() cmd = input("command: ").split() if tools.site["checker"].driver!=None: tools.site["checker"].driver.quit()
price_html = soup.find_all(id="teaLeaf-value-text757") #That returns a long string of htlml, turn that into a list. #then split that list at the Greater than sign. price_html_as_list = ((str(price_html).split('>'))) #the price falls into the 2nd from last spot in the list so i set it as price_short #it is then saved as a sting as price_short price_short = (price_html_as_list[-2]) #split up price_short at the less than sign #then take the first part of it containing the price #this outputs the price as a list with the $ at the beginning price_full = (price_short).split('<')[0] value = Decimal(sub(r'[^\d.]', '', price_full)) print(value) tools.check(value) ### Whats the current thought process? ### """ """ '''for i in range(0, len(soup.findAll('h4'))): check = str(soup.findAll('h4')[i]) this = check.split() if this[7] != "Bahamas": x=x+1 good_cruises.update({x: this[7:-2]}) for x,y in good_cruises.items(): print("Cruise number " + str(x) + " is going to " + str(' '.join(y)) + " cruise.")