本文整理汇总了Python中schedule.Schedule类的典型用法代码示例。如果您正苦于以下问题:Python Schedule类的具体用法?Python Schedule怎么用?Python Schedule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Schedule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: theLoop
def theLoop(adapters,log):
log.debug("starting scheduler class")
sch=Schedule(log)
while 1:
log.debug("starting loop")
log.debug("updating schedule")
sch.makeschedule()
row=sch.getnextschedule()
now=int(time.time())
left=3600
togo=3600
if len(row):
togo=row["start"] - now
log.debug("next recording: %s in %s" % (row["title"],timeformat(togo)))
else:
log.debug("no recordings scheduled")
rrows=sch.getcurrentrecordings()
cn=len(rrows)
if cn:
log.debug("%d programmes currently being recorded" % cn)
nextend=rrows[0]["end"]
left=nextend - now
log.debug("%s finishes in %s" % (rrows[0]["title"],timeformat(left)))
else:
log.debug("nothing currently recording")
if togo<left:
timeleft=togo
else:
timeleft=left
log.debug("sleeping for %s" % timeformat(timeleft))
signal.alarm(left)
signal.pause()
log.debug("ending loop")
示例2: schedule
def schedule(option, opt_str, value, parser):
sched = Schedule()
schedate = datetime.strptime(value, '%m/%d/%Y')
print "Games scheduled for %s:" %schedate.strftime("%m/%d/%Y")
for match in sched.date(schedate):
print match.without_date()
示例3: load
def load(feed_filename, db_filename=":memory:"):
schedule = Schedule(db_filename)
schedule.create_tables()
fd = feed.Feed(feed_filename)
for gtfs_class in (Agency,
Route,
Stop,
Trip,
StopTime,
ServicePeriod,
ServiceException,
Fare,
FareRule,
ShapePoint,
Frequency,
Transfer,
):
try:
for i, record in enumerate(fd.get_table(gtfs_class.TABLENAME + ".txt")):
if i % 500 == 0:
schedule.session.commit()
instance = gtfs_class(**record.to_dict())
schedule.session.add(instance)
except KeyError:
# TODO: check if the table is required
continue
schedule.session.commit()
return schedule
示例4: form
def form(request) :
sched = Schedule(DBSession)
stop_id = request.matchdict.get("stop_id", "").upper()
stop = sched.getstop(stop_id)
q = sched.stop_form(stop_id)
ret = calc_form(q)
return {'stop': stop, 'date': date.today(), 'routedirs': ret['sd'], 'stops': ret['ss']}
示例5: json_hor
def json_hor(request):
sched = Schedule(DBSession)
stop_id = request.GET.get("stop_id").strip().upper()
stop = sched.getstop(stop_id)
if stop is None :
data = {}
else :
if stop.is_station :
liste_stops = stop.child_stations
else :
liste_stops = [stop]
d = request.GET.get("date")
if d is None :
ddate = date.today()
else :
d = d.replace('-','')
ddate = date(int(d[4:8]), int(d[2:4]), int(d[0:2]))
routedir_id = request.GET.get("routedir_id")
print "route:", routedir_id
if routedir_id is None or routedir_id == 'ALL' :
route_id = None
direction_id = None
else:
route_id, direction_id = routedir_id.split('#')
trips = sched.horaire(liste_stops, d=ddate, route_id=route_id, direction_id=direction_id)
data = [{'heure': h.departure,
'ligne': t.route.route_short_name,
'sens': 'gauche' if t.direction_id == 1 else 'droite',
'terminus': t.terminus.stop_name,
'stop': h.stop_id,
'trip_id': t.trip_id
} for (h, t) in trips]
head =['Heure', 'Ligne', 'Sens', 'Terminus', 'Arrêt']
return {'head':head, 'data':data}
示例6: json_form
def json_form(request):
sched = Schedule(DBSession)
stop_id = request.GET.get("stop_id")
q = sched.stop_form(stop_id)
ret = calc_form(q)
sd = ret['sd']
return [{'route_id':s[0], 'direction_id':s[1], 'trip_headsign': s[2], 'route_short_name': s[3]}
for s in sorted(sd, key=itemgetter(0,1))]
示例7: json_stops
def json_stops(request):
sched = Schedule(DBSession)
term = request.GET.get("query")
# minimum 2 caractères pour renvoyer
if len(term) < 2 :
return []
else :
return [{'id':s.stop_id, 'name':s.stop_name, 'commune':s.stop_desc} for s in sched.liste_stations(term)]
示例8: test_exchange_column
def test_exchange_column(self):
"""Tests the exchanging of columns in the schedule"""
t = 10
s = Schedule(t, t)
self.assertTrue(s.c[0] == 0)
self.assertTrue(s.c[1] == 1)
s.exchange_column(0, 1)
self.assertTrue(s.c[0] == 1)
self.assertTrue(s.c[1] == 0)
示例9: accueil
def accueil(request) :
route = request.matched_route.name
if route in ('index', 'accueil') :
return {}
else :
sched = Schedule(DBSession)
stop_id = request.matchdict.get("stop_id", "").upper()
stop = sched.getstop(stop_id)
return {'stop': stop}
示例10: get_schedule
def get_schedule(self, activity_list):
S = Schedule(self.problem)
self.al_iter = activity_list.__iter__()
for i in xrange(self.problem.num_activities):
activity = self._select_activity()
precedence_feasible_start = S.earliest_precedence_start(activity)
real_start = self._compute_real_start(S, activity, precedence_feasible_start)
S.add(activity, real_start, force=True)
return S
示例11: main
def main():
"""
The main function of the program that turns user input into a schedule and
uses a genetic algorithm to find an optimal schedule.
"""
# Container for user input.
info = {}
# Get the desired term and courses.
if DEBUG:
info["term"] = "FA16"
info["courses"] = ["CSE 12", "CSE 15L", "DOC 1"]
elif handleInput(info):
return
print("Finding schedule data...")
# Get the schedule data for the given courses and term.
schedule = Schedule()
schedule.term = info["term"]
schedule.courses = info["courses"]
try:
scheduleData = schedule.retrieve()
except ClassParserError:
print("The Schedule of Classes data could not be loaded at this " \
"or you have provided an invalid class.")
return
# Make sure all of the desired classes were found.
for course in info["courses"]:
if course not in scheduleData:
print("'" + course + "' was not found in the Schedule of Classes!")
return
# Initiate the population.
algorithm = Algorithm(scheduleData)
algorithm.initiate(CAPACITY, CROSSOVER, MUTATE, ELITISM)
# Run the algorithm through the desired number of generations.
generation = 0
highest = 0
while generation < GENERATIONS:
algorithm.evolve()
generation += 1
print("Generating... "
+ str(int((generation / GENERATIONS) * 100)) + "%", end="\r")
print("\nDone!")
algorithm.printFittest()
示例12: should_add_up
def should_add_up(self):
schedule = Schedule()
schedule.add_lesson(RandomWeeklyLesson())
schedule.add_lesson(RandomWeeklyLesson())
b = Bins(schedule=schedule)
b_ = b.bins()
expect(b[0] + b[1] + b[2] + b[3] + b[4] + b[5]).to.equal(2)
expect(b_[0] + b_[1] + b_[2] + b_[3] + b_[4] + b_[5]).to.equal(2)
示例13: should_delegate_to_df
def should_delegate_to_df(self):
l1_1 = WeeklyLesson(start_time=0, day_of_week=0)
l1_2 = WeeklyLesson(start_time=1, day_of_week=0)
l1_3 = WeeklyLesson(start_time=0.5, day_of_week=0)
lessons_1 = [l1_1, l1_2, l1_3]
s = Schedule(lessons=lessons_1, timezone=Timezone('Abu Dhabi'))
expect(s.sum().sum()).to.equal(3)
示例14: should_return_the_timezone_object
def should_return_the_timezone_object(self):
timezone = Timezone('Abu Dhabi')
l1_1 = WeeklyLesson(start_time=0, day_of_week=0)
l1_2 = WeeklyLesson(start_time=1, day_of_week=0)
l1_3 = WeeklyLesson(start_time=0.5, day_of_week=0)
lessons = [l1_1, l1_2, l1_3]
s = Schedule(lessons=lessons, timezone=timezone)
expect(s.timezone()).to.equal(timezone)
示例15: main
def main(args, app):
if not args.rrule:
msg = "Could not parse rrule specification: %s" % " ".join(sys.argv[3:])
print "Error:", msg
raise Exception(msg)
new_schedule = Schedule(name=args.name, rrule=args.rrule, phases=" ".join([]))
if not args.preview:
new_schedule.store(app.config)
app.config.save()
print "added", new_schedule.format_url()