本文整理匯總了Python中schedule.clear方法的典型用法代碼示例。如果您正苦於以下問題:Python schedule.clear方法的具體用法?Python schedule.clear怎麽用?Python schedule.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類schedule
的用法示例。
在下文中一共展示了schedule.clear方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
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)
示例2: go_generate_daily_sched
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
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)
示例3: read_new_article
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
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
示例4: resume
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
def resume(self):
self.__exit_flag.clear()
示例5: pause
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
def pause(self):
self.__in_progress.clear()
self.xx_obj.stop()
示例6: quit
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
def quit(self):
self.__running.clear()
self.xx_obj.close()
示例7: stop_click
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
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')
示例8: exit_handler
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
def exit_handler(signum, frame):
log.info("Received %s, canceling jobs and exiting.", signal.Signals(signum).name)
schedule.clear()
exit()
############################################################
# MAIN
############################################################
示例9: reloadSchedule
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
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 #
# #
##############################################################################
示例10: scheduleRechecking
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
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")
示例11: scheduler
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
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)
示例12: list_jobs
# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import clear [as 別名]
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))