本文整理汇总了Python中Scheduler.Scheduler类的典型用法代码示例。如果您正苦于以下问题:Python Scheduler类的具体用法?Python Scheduler怎么用?Python Scheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Scheduler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure
def configure(self, cfg_params):
self.environment_unique_identifier = None
self.cfg_params = cfg_params
Scheduler.configure(self,cfg_params)
self.jobtypeName = cfg_params['CRAB.jobtype']
name=string.upper(self.name())
self.queue = cfg_params.get(name+'.queue',None)
self.res = cfg_params.get(name+'.resource',None)
# minimal padding time for jobs. For local schedulers is disabled.
# Added for alignment purpose only (and for test) with Grid schedulers
self.minimal_job_duration = 0
if (cfg_params.has_key(self.name()+'.env_id')): self.environment_unique_identifier = cfg_params[self.name()+'.env_id']
## is this ok?
localDomainName = getLocalDomain(self)
localPSNs = getListOfPSNsForThisDomain(localDomainName)
# turn list to a string as in crab.cfg
localPSNs = ",".join(localPSNs)
if not cfg_params.has_key('GRID.se_white_list'):
cfg_params['GRID.se_white_list']=localPSNs
common.logger.info("Your domain name is "+str(localDomainName)+": only local dataset will be considered")
else:
common.logger.info("Your se_white_list is set to "+str(cfg_params['GRID.se_white_list'])+": only local dataset will be considered")
return
示例2: runInViSyBlE
def runInViSyBlE():
SIFTObjectDetector.loadDatabase("/home/venkat/Documents/Projects/InViSyBle/ObjectDatabase/")
FaceRecognizer.loadDatabase("/home/venkat/Documents/Projects/InViSyBle/FaceDatabase/")
#cap = cv2.VideoCapture(0)
#getFrame = GetFrame()
#getBWFrame = GetBWFrame()
scheduler = Scheduler()
scheduler.updateComputationList([GetFrame, SIFTObjectDetector.SIFTObjectDetector, FaceDetector, FaceRecognizer.FaceRecognizer])
while(True):#cap.isOpened()):
#ret, frame = cap.read()
#gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
#frame = getFrame((0,0), None)
#frame, frameId = getBWFrame(frame, None)
res = scheduler.compute()
if None in res:
continue
frame, frameId = res[0]
detectedObjects = res[1]
detectedFaces = res[3]
#draw face rectangles
faces = res[2]
for (x,y,w,h) in faces:
cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),2)
cv2.imshow('frame',frame)
print detectedObjects, detectedFaces
if cv2.waitKey(1) & 0xFF == ord('q'):
break
#cap.release()
cv2.destroyAllWindows()
示例3: __init__
def __init__(self, harness, params):
Scheduler.__init__(self, harness, params)
# json storage
self.__session_data = {}
# a set containing any launched jobs
self.__jobs = set([])
# Open existing session file
if os.path.exists(self.options.session_file):
self.__status_check = True
try:
self.__session_file = open(self.options.session_file, 'r+')
self.__session_data = json.load(self.__session_file)
# Set some important things that affect findAndRunTests (input file, --re)
json_args = self.getData('QUEUEMANAGER',
options_regexp=True,
options_input=True)
self.options.reg_exp = json_args['options_regexp']
self.options.input_file_name = json_args['options_input']
except ValueError:
raise QueueManagerError('Supplied session file: %s exists, but is not readable!' % (self.options.session_file))
# session file does not exists. Create one instead.
else:
self.__status_check = False
self.__session_file = self.__createSessionFile()
self.putData('QUEUEMANAGER',
options_regexp=self.options.reg_exp,
options_input=self.options.input_file_name)
self.params = params
示例4: __init__
def __init__(self):
self.http = httplib2.Http()
self.config = ConfigurationServer.get('AutoOn')
if self.config == None:
self.config = {
'lat': 0,
'long': 0,
'city': 'Enter a city here...',
'offset': 0,
'autoOnGroup': 'All Lights',
'groupBri': 255,
}
else:
if not 'autoOnGroup' in self.config.keys():
self.config['autoOnGroup'] = 'All Lights'
if not 'groupBri' in self.config.keys():
self.config['groupBri'] = 255
minute = random.randint(0,59)
start_date = datetime.datetime.combine(datetime.datetime.today(), datetime.time(hour=12, minute=minute, second=0)) #added randomness to not break earthtools :)
if start_date < datetime.datetime.now():
# get the sunset for today, the get_sunset function will take care of the rest
self.get_sunset()
start_date += datetime.timedelta(days=1)
Scheduler.add_interval_job(self.get_sunset, days=1, start_date=start_date)
示例5: startup
def startup(self, bridge_ip):
from Plugins import Plugins
from HueBridge import HueBridge
HueBridge.init(bridge_ip)
HueBridge.update()
self.plugins = Plugins #expose it for cherrypy
# Automatically update every minute
Scheduler.add_interval_job(HueBridge.update, minutes=1)
示例6: configure
def configure(self, cfg_params):
self.cfg_params = cfg_params
self.jobtypeName = cfg_params.get('CRAB.jobtype','')
self.schedulerName = cfg_params.get('CRAB.scheduler','')
Scheduler.configure(self,cfg_params)
#self.proxyValid=0
#self.dontCheckProxy=int(cfg_params.get("GRID.dont_check_proxy",0))
self.space_token = cfg_params.get("USER.space_token",None)
self.proxyServer= 'myproxy.cern.ch'
#self.group = cfg_params.get("GRID.group", None)
#self.role = cfg_params.get("GRID.role", None)
removeBList = cfg_params.get("GRID.remove_default_blacklist", 0 )
blackAnaOps = None
if int(removeBList) == 0:
blacklist = Downloader("http://cmsdoc.cern.ch/cms/LCG/crab/config/")
result = blacklist.config("site_black_list.conf")
if result != None:
blackAnaOps = result
common.logger.debug("Enforced black list: %s "%blackAnaOps)
else:
common.logger.info("WARNING: Skipping default black list!")
self.EDG_ce_black_list = None
if cfg_params.has_key('GRID.ce_black_list') and cfg_params['GRID.ce_black_list']:
self.EDG_ce_black_list = cfg_params.get('GRID.ce_black_list')
if int(removeBList) == 0 and blackAnaOps:
self.EDG_ce_black_list += ",%s"%blackAnaOps
elif int(removeBList) == 0 and blackAnaOps:
self.EDG_ce_black_list = blackAnaOps
if self.EDG_ce_black_list:
self.EDG_ce_black_list = str(self.EDG_ce_black_list).split(',')
self.EDG_ce_white_list = cfg_params.get('GRID.ce_white_list',None)
if (self.EDG_ce_white_list): self.EDG_ce_white_list = str(self.EDG_ce_white_list).split(',')
self.VO = cfg_params.get('GRID.virtual_organization','cms')
self.EDG_clock_time = cfg_params.get('GRID.max_wall_clock_time',None)
# Default minimum CPU time to >= 130 minutes
self.EDG_cpu_time = cfg_params.get('GRID.max_cpu_time', '130')
## Add EDG_WL_LOCATION to the python path
#if not self.CRAB_useServer and not self.CRAB_serverName:
# if not os.environ.has_key('EDG_WL_LOCATION'):
# msg = "Error: the EDG_WL_LOCATION variable is not set."
# raise CrabException(msg)
# path = os.environ['EDG_WL_LOCATION']
# libPath=os.path.join(path, "lib")
# sys.path.append(libPath)
# libPath=os.path.join(path, "lib", "python")
# sys.path.append(libPath)
self.checkProxy()
return
示例7: __init__
def __init__(self, name):
Scheduler.__init__(self,name)
self.states = [ "Acl", "cancelReason", "cancelling","ce_node","children", \
"children_hist","children_num","children_states","condorId","condor_jdl", \
"cpuTime","destination", "done_code","exit_code","expectFrom", \
"expectUpdate","globusId","jdl","jobId","jobtype", \
"lastUpdateTime","localId","location", "matched_jdl","network_server", \
"owner","parent_job", "reason","resubmitted","rsl","seed",\
"stateEnterTime","stateEnterTimes","subjob_failed", \
"user tags" , "status" , "status_code","hierarchy"]
return
示例8: buildGivenPackages
def buildGivenPackages (self, listPackages):
returnVal=self.calculateParams(listPackages)
if not returnVal:
self.logger.error("Unable to set paramaters. Terminating the package manager.")
return False
statusEvent=threading.Event()
numWorkerThreads=self.calculatePossibleNumWorkerThreads()
if numWorkerThreads > 8:
numWorkerThreads = 8
if numWorkerThreads == 0:
return False
self.initializeScheduler(statusEvent)
self.initializeThreadPool(statusEvent)
i=0
while i < numWorkerThreads:
workerName="WorkerThread"+str(i)
ThreadPool.addWorkerThread(workerName)
ThreadPool.startWorkerThread(workerName)
i = i + 1
statusEvent.wait()
Scheduler.stopScheduling=True
self.logger.info("Waiting for all remaining worker threads")
listWorkerObjs=ThreadPool.getAllWorkerObjects()
for w in listWorkerObjs:
w.join()
setFailFlag=False
allPackagesBuilt=False
if Scheduler.isAnyPackagesFailedToBuild():
setFailFlag=True
if Scheduler.isAllPackagesBuilt():
allPackagesBuilt=True
if setFailFlag:
self.logger.error("Some of the packages failed:")
self.logger.error(Scheduler.listOfFailedPackages)
return False
if not setFailFlag:
if allPackagesBuilt:
self.logger.info("All packages built successfully")
else:
self.logger.error("Build stopped unexpectedly.Unknown error.")
return False
self.logger.info("Terminated")
return True
示例9: get_sunset
def get_sunset(self):
# 0,0 is a gps coordinate somewhere in the South Atlantic Ocean, hopefully nobody uses Hue there :)
if self.config['lat'] != 0 and self.config['long'] != 0:
now = datetime.datetime.now()
request_url = "{}/{}/{}/{}/{}/99/1".format(EARTHTOOLS_URL, self.config['lat'], self.config['long'], now.day, now.month)
resp, content = self.http.request(request_url, method="GET")
if int(resp['status']) == 200:
xml = ElementTree.fromstring(content)
sunset = xml.find(".//evening/sunset")
sunset_time = time.strptime(sunset.text, "%H:%M:%S")
sunset_datetime = datetime.datetime(now.year, now.month, now.day, sunset_time.tm_hour, sunset_time.tm_min, sunset_time.tm_sec) + datetime.timedelta(minutes=self.config['offset'])
if sunset_datetime > datetime.datetime.now():
cherrypy.log("AutoOn: Turning lights on @ {}".format(sunset_datetime))
Scheduler.add_date_job(self.turn_lights_on, sunset_datetime)
示例10: buildGivenPackages
def buildGivenPackages (self, listPackages, buildThreads):
if constants.rpmCheck:
alreadyBuiltRPMS=self.readAlreadyAvailablePackages()
listPackages=list(set(listPackages)|(set(constants.listMakeCheckRPMPkgtoInstall)-set(alreadyBuiltRPMS)))
returnVal=self.calculateParams(listPackages)
if not returnVal:
self.logger.error("Unable to set paramaters. Terminating the package manager.")
raise Exception("Unable to set paramaters")
statusEvent=threading.Event()
self.initializeScheduler(statusEvent)
self.initializeThreadPool(statusEvent)
i=0
while i < buildThreads:
workerName="WorkerThread"+str(i)
ThreadPool.addWorkerThread(workerName)
ThreadPool.startWorkerThread(workerName)
i = i + 1
statusEvent.wait()
Scheduler.stopScheduling=True
self.logger.info("Waiting for all remaining worker threads")
listWorkerObjs=ThreadPool.getAllWorkerObjects()
for w in listWorkerObjs:
w.join()
setFailFlag=False
allPackagesBuilt=False
if Scheduler.isAnyPackagesFailedToBuild():
setFailFlag=True
if Scheduler.isAllPackagesBuilt():
allPackagesBuilt=True
if setFailFlag:
self.logger.error("Some of the packages failed:")
self.logger.error(Scheduler.listOfFailedPackages)
raise Exception("Failed during building package")
if not setFailFlag:
if allPackagesBuilt:
self.logger.info("All packages built successfully")
else:
self.logger.error("Build stopped unexpectedly.Unknown error.")
raise Exception("Unknown error")
self.logger.info("Terminated")
示例11: __init__
def __init__(self, justPlots = False):
self.__name__ = "Core"
self.configManager = ConfigurationManager()
# These return True of False depending on whether loading the conf was a success.
# It should be checked if the conf was loaded successfully and failures should be logged.
self.configManager.loadConf(CONFIG_CORE, True)
self.configManager.loadConf(CONFIG_SETTINGS, True)
self.configManager.loadConf(CONFIG_FORMS, True)
self.configManager.loadConf(CONFIG_URLMAP, True)
self.configManager.loadConf(CONFIG_MESSAGES, True)
self.moduleManager = ModuleManager(self)
self.settingsManager = SettingsManager(self)
self.clientManager = ClientManager(self)
self.sensorManager = SensorManager(self)
self.deviceManager = DeviceManager(self)
self.taskManager = TaskManager(self)
self.messageManager = MessageManager(self)
self.logging = Logging(self)
if self.settingsManager.equals("plottype", "matplotlib"):
from Plot import Plot
self.plot = Plot(self)
self.protocol = Protocol(self)
if not justPlots: self.connection = Connection(self)
if not justPlots: self.scheduler = Scheduler()
if not justPlots: self.webServer = WebServer(self.connection.getLocalIP(), self.settingsManager.getValueByName("listenport")) # Currently binds to localhost. But this needs to be fixed so other connections can be listened to too.
示例12: setUp
def setUp(self):
self.pcb1 = PCB(3, 5, 20, 40, 4)
self.pcb2 = PCB(8, 10, 25, 42, 3)
self.pcb3 = PCB(20, 30, 15, 45, 5)
self.pcb4 = PCB(46, 49, 5, 6, 1)
self.scheduler = Scheduler()
示例13: __init__
def __init__(self, portTypes = {} ):
Scheduler.__init__(self)
self.motors = { 'A': Motor(BP.PORT_A, self), 'B': Motor(BP.PORT_B, self), 'C': Motor(BP.PORT_C, self), 'D': Motor(BP.PORT_D, self) }
self.sensors = { }
BP.BrickPiSetup() # setup the serial port for communication
for port, sensorType in portTypes.items():
if isinstance(sensorType, int):
sensor = Sensor(port, sensorType)
else:
sensor = sensorType(port)
self.sensors[sensor.idChar] = sensor
BP.BrickPi.SensorType[sensor.port] = sensor.type
BP.BrickPiSetupSensors() #Send the properties of sensors to BrickPi
self.setUpdateCoroutine( self.updaterCoroutine() )
示例14: __start
def __start(self, month=None, year=None):
'''
Does basic configuration from user input
'''
if (month == None or year == None) or (month not in range(1,13) and year <= 0):
self.printTitle()
print("Let's get started by filling out some basic information:")
self.year = self.getInputOfType("Enter the current year: ", 'int', range(0,2500))
self.month = self.getInputOfType("Enter the current month (numeric): ", 'int', range(1,13))
self.scheduler = Scheduler(self.month, self.year)
name = self.getInputOfType("[Optional] Enter name of your restaurant: ", "str", range(0,20), True)
if name != "skip":
self.schedName = name
self.printTitle()
print("Scheduler configured for %s %s"%(self.monthNames[self.month], self.year))
print("")
print("Here is an overview of the month:")
self.printCalendar()
print("")
print("You should start by adding Employees and then specifying availability/rules for each employee. " +
"Then set shifts for each day/week of the month.")
print("")
print("Type help at any time for help using this app.\n")
示例15: __init__
def __init__(self, harness, params):
Scheduler.__init__(self, harness, params)
# json storage
self.__session_data = {}
# Open existing session file
if os.path.exists(self.options.session_file):
self.__status_check = True
try:
self.__session_file = open(self.options.session_file, 'r+')
self.__session_data = json.load(self.__session_file)
# Set some important things that affect findAndRunTests (input file, --re)
json_args = self.getData('QUEUEMANAGER',
options_regexp=True,
options_input=True,
options_timing=True)
self.options.input_file_name = json_args['options_input']
# Honor any new reg_exp supplied by the user
if self.options.reg_exp:
pass
else:
self.options.reg_exp = json_args['options_regexp']
# Only allow timing if user is asking, and user supplied those options
# during initial launch phase (otherwise perflog will not be available).
if not json_args['options_timing'] and self.options.timing:
self.options.timing = False
except ValueError:
print('Supplied session file: %s exists, but is not readable!' % (self.options.session_file))
sys.exit(1)
# session file does not exists. Create one instead.
elif not self.options.queue_cleanup:
self.__status_check = False
self.__session_file = self.__createSessionFile()
self.putData('QUEUEMANAGER',
options_regexp=self.options.reg_exp,
options_input=self.options.input_file_name,
options_timing=self.options.timing)
self.params = params