Python schedule.clear() Examples
The following are 12
code examples of schedule.clear().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
schedule
, or try the search function
.
Example #1
Source File: xuexi.py From autoxuexi with GNU General Public License v3.0 | 8 votes |
def __init__(self, use_Dingtalk=False): chrome_options = Options() self.__exit_flag = threading.Event() self.__exit_flag.clear() self.use_Dingtalk = use_Dingtalk if config['mute']: chrome_options.add_argument('--mute-audio') # 关闭声音 if os.path.exists('driver/chrome.exe'): chrome_options.binary_location = 'driver/chrome.exe' # chrome_options.add_argument('--no-sandbox')#解决DevToolsActivePort文件不存在的报错 # chrome_options.add_argument('window-size=800x600') #指定浏览器分辨率 # chrome_options.add_argument('--disable-gpu') #谷歌文档提到需要加上这个属性来规避bug # chrome_options.add_argument('--hide-scrollbars') #隐藏滚动条, 应对一些特殊页面 # chrome_options.add_argument('blink-settings=imagesEnabled=false') #不加载图片, 提升速度 if config['background_process'] and self.use_Dingtalk: chrome_options.add_argument('--headless') # 浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败 self.driver = webdriver.Chrome('driver/chromedriver.exe', options=chrome_options) LOGGER.setLevel(logging.CRITICAL)
Example #2
Source File: PseudoChannel.py From pseudo-channel with GNU General Public License v3.0 | 5 votes |
def go_generate_daily_sched(): """Saving current daily schedule as cached .json""" pseudo_channel.save_daily_schedule_as_json() schedule.clear('daily-tasks') sleep(1) try: pseudo_channel.generate_daily_schedule() except: print("----- Recieved error when running generate_daily_schedule()") generate_memory_schedule(pseudo_channel.db.get_daily_schedule(), True)
Example #3
Source File: xuexi.py From autoxuexi with GNU General Public License v3.0 | 5 votes |
def read_new_article(self): article_url = 'https://www.xuexi.cn/lgdata/1jscb6pu1n2.json' try: resp = requests.get(article_url, proxies=config['proxies'] if config['use_proxy'] else {}) except Exception: raise TimeoutError('Timeout') resp_list = eval(resp.text) self.__exit_flag.clear() for link in resp_list: try: if not read_check(link['itemId'], 'article'): continue self.driver.get(link['url']) app.log(u'正在学习文章:%s' % link['title']) while not self.__exit_flag.isSet(): ActionChains(self.driver).key_down(Keys.DOWN).perform() self.driver.execute_script(""" (function(){ if (document.documentElement.scrollTop + document.documentElement.clientHeight >= document.documentElement.scrollHeight*0.9){ document.title = 'scroll-done';} })(); """) if u'scroll-done' in self.driver.title: break else: self.__exit_flag.wait(random.randint(2, 5)) app.log(u'%s 学习完毕' % link['title']) yield True except Exception as error: logging.debug(error) yield False
Example #4
Source File: xuexi.py From autoxuexi with GNU General Public License v3.0 | 5 votes |
def resume(self): self.__exit_flag.clear()
Example #5
Source File: xuexi.py From autoxuexi with GNU General Public License v3.0 | 5 votes |
def pause(self): self.__in_progress.clear() self.xx_obj.stop()
Example #6
Source File: xuexi.py From autoxuexi with GNU General Public License v3.0 | 5 votes |
def quit(self): self.__running.clear() self.xx_obj.close()
Example #7
Source File: xuexi.py From autoxuexi with GNU General Public License v3.0 | 5 votes |
def stop_click(self): schedule.clear() self.__monitor_flag.clear() self.quit_click() # def show_img(self, pil_image): # tk_image = ImageTk.PhotoImage(pil_image) # self.label_img = Label(root, image = tk_image) # self.label_img.grid(row=2, column=0, padx=5, pady=5, columnspan=3, sticky='NSWE')
Example #8
Source File: traktarr.py From traktarr with GNU General Public License v3.0 | 5 votes |
def exit_handler(signum, frame): log.info("Received %s, canceling jobs and exiting.", signal.Signals(signum).name) schedule.clear() exit() ############################################################ # MAIN ############################################################
Example #9
Source File: thermostat.py From thermostat with MIT License | 5 votes |
def reloadSchedule(): with scheduleLock: schedule.clear() activeSched = None with thermostatLock: thermoSched = JsonStore( "thermostat_schedule.json" ) if holdControl.state != "down": if heatControl.state == "down": activeSched = thermoSched[ "heat" ] log( LOG_LEVEL_INFO, CHILD_DEVICE_SCHEDULER, MSG_SUBTYPE_CUSTOM + "/load", "heat" ) elif coolControl.state == "down": activeSched = thermoSched[ "cool" ] log( LOG_LEVEL_INFO, CHILD_DEVICE_SCHEDULER, MSG_SUBTYPE_CUSTOM + "/load", "cool" ) if useTestSchedule: activeSched = getTestSchedule() log( LOG_LEVEL_INFO, CHILD_DEVICE_SCHEDULER, MSG_SUBTYPE_CUSTOM + "/load", "test" ) print "Using Test Schedule!!!" if activeSched != None: for day, entries in activeSched.iteritems(): for i, entry in enumerate( entries ): getattr( schedule.every(), day ).at( entry[ 0 ] ).do( setScheduledTemp, entry[ 1 ] ) log( LOG_LEVEL_DEBUG, CHILD_DEVICE_SCHEDULER, MSG_SUBTYPE_TEXT, "Set " + day + ", at: " + entry[ 0 ] + " = " + str( entry[ 1 ] ) + scaleUnits ) ############################################################################## # # # Web Server Interface # # # ##############################################################################
Example #10
Source File: scheduler.py From scrape with MIT License | 5 votes |
def scheduleRechecking(): """ Schedules Rechecking every 30 mins incase of pending tasks or errors """ schedule.clear("daily-task") schedule.every(30).minutes.do(scheduleAllSpiders).tag("recheck-task")
Example #11
Source File: silvia-pi.py From silvia-pi with MIT License | 4 votes |
def scheduler(dummy,state): import time import sys import schedule from datetime import datetime sys.stdout = open("scheduler.log", "a", buffering=0) sys.stderr = open("scheduler.err.log", "a", buffering=0) print "Starting scheduler thread ..." last_wake = 0 last_sleep = 0 last_sched_switch = 0 while True: if last_wake != state['wake_time'] or last_sleep != state['sleep_time'] or last_sched_switch != state['sched_enabled']: schedule.clear() if state['sched_enabled'] == True: schedule.every().day.at(state['sleep_time']).do(gotosleep,1,state) schedule.every().day.at(state['wake_time']).do(wakeup,1,state) nowtm = float(datetime.now().hour) + float(datetime.now().minute)/60. sleeptm = state['sleep_time'].split(":") sleeptm = float(sleeptm[0]) + float(sleeptm[1])/60. waketm = state['wake_time'].split(":") waketm = float(waketm[0]) + float(waketm[1])/60. if waketm < sleeptm: if nowtm >= waketm and nowtm < sleeptm: wakeup(1,state) else: gotosleep(1,state) elif waketm > sleeptm: if nowtm < waketm and nowtm >= sleeptm: gotosleep(1,state) else: wakeup(1,state) else: wakeup(1,state) last_wake = state['wake_time'] last_sleep = state['sleep_time'] last_sched_switch = state['sched_enabled'] schedule.run_pending() time.sleep(1)
Example #12
Source File: scheduler.py From scrape with MIT License | 4 votes |
def list_jobs(): """List jobs in a user-friends manner This method should only be used when the script is not being used as a service. """ # Clear the console os.system('clear') # Get Current Time curr_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # Print Header print("++++++++ Scrapyd Scheduler (thisisayush) ++++++++") print("================= "+curr_time+" =================") print(" [ CHECK LOG FILE FOR ERRORS ] [PID: " + str(os.getpid()) + "]") print("- Running Schedules: (Updated Every 1 minute)") # Print Current Schedules print(schedule.jobs) # Start Printing Schedules on Scrapyd Server print("- Running Schedules on Server: ") try: r = requests.get(api_url + 'listprojects.json') projects = r.json() for project in projects['projects']: print(" === "+project+" ===") r = requests.get(api_url + 'listjobs.json', params = { 'project':project }) jobs = r.json() print("+ Pending Jobs:") for pending_jobs in jobs['pending']: print(" |_ "+pending_jobs['spider']+" ("+ pending_jobs['id']+")") print("+ Completed Jobs:") for completed_jobs in jobs['finished']: print(" |_ "+completed_jobs['spider']+" ("+ completed_jobs['id']+") ") print(" START: "+completed_jobs['start_time']+" END: "+completed_jobs['end_time']) print("+ Running Jobs:") for running_jobs in jobs['running']: print(" |_ "+running_jobs['spider']+" ("+running_jobs['id']+") START: "+running_jobs['start_time']) except Exception as e: logger.error(__name__ + " [UNHANDLED] " + str(e)) print("Error:" +str(e))