本文整理汇总了Python中schedule.Schedule类的典型用法代码示例。如果您正苦于以下问题:Python Schedule类的具体用法?Python Schedule怎么用?Python Schedule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Schedule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
开发者ID:ccdale,项目名称:cristel,代码行数:34,代码来源:cristel.py
示例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()
开发者ID:elconde,项目名称:nhlbot,代码行数:7,代码来源:nhlbot.py
示例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
开发者ID:alexcarruthers,项目名称:gtfs,代码行数:34,代码来源:loader.py
示例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']}
开发者ID:philippechataignon,项目名称:easytan,代码行数:7,代码来源:views.py
示例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}
开发者ID:philippechataignon,项目名称:easytan,代码行数:34,代码来源:views.py
示例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))]
开发者ID:philippechataignon,项目名称:easytan,代码行数:8,代码来源:views.py
示例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)]
开发者ID:philippechataignon,项目名称:easytan,代码行数:8,代码来源:views.py
示例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)
开发者ID:absalon-james,项目名称:velopyraptor,代码行数:9,代码来源:test_schedule.py
示例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}
开发者ID:philippechataignon,项目名称:easytan,代码行数:9,代码来源:views.py
示例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
开发者ID:Artimi,项目名称:ukko,代码行数:9,代码来源:sgs.py
示例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()
开发者ID:brianhang,项目名称:tritonscheduler,代码行数:56,代码来源:main.py
示例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)
开发者ID:Edderic,项目名称:udacity-machine-learning-nanodegree,代码行数:10,代码来源:bins_spec.py
示例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)
开发者ID:Edderic,项目名称:udacity-machine-learning-nanodegree,代码行数:10,代码来源:schedule_spec.py
示例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)
开发者ID:Edderic,项目名称:udacity-machine-learning-nanodegree,代码行数:10,代码来源:schedule_spec.py
示例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()
开发者ID:openaps,项目名称:oacids,代码行数:10,代码来源:add.py
示例16: test_exhange_row
def test_exhange_row(self):
"""Tests the exchanging of rows in the schedule"""
t = 10
s = Schedule(t, t)
self.assertTrue(s.d[0] == 0)
self.assertTrue(s.d[1] == 1)
# Swap rows 0 and 1
s.exchange_row(0, 1)
self.assertTrue(s.d[0] == 1)
self.assertTrue(s.d[1] == 0)
开发者ID:absalon-james,项目名称:velopyraptor,代码行数:10,代码来源:test_schedule.py
示例17: handleInput
def handleInput(info):
"""
Handles prompting for user input and validating user input. The results of
valid input are stored in the info dictionary.
:param info: where user input is stored
:returns: whether or not the program should close
"""
term = None
# Get which term will be used.
try:
term = input("Enter your desired term (example: FA16): ")
except:
print("")
return True
# Validate the format of the term.
while not Schedule.validateTerm(term):
term = input("You have entered an invalid term, try again: ")
# Get all the desired courses.
print("Enter all of your desired classes on a separate line.")
print("To finish entering classes, input an empty line.")
courses = []
while True:
try:
course = input()
if course:
if Schedule.validateCourse(course):
courses.append(course.upper())
else:
print("'" + course + "' is not a valid course code.")
else:
break
except KeyboardInterrupt:
return True
except:
break
# Validate if any courses were entered.
if len(courses) == 0:
print("You did not enter any courses.")
return True
# Send the user input to the main function.
info["term"] = term.upper()
info["courses"] = courses
return False
开发者ID:brianhang,项目名称:tritonscheduler,代码行数:55,代码来源:main.py
示例18: json_map
def json_map(request):
sched = Schedule(DBSession)
latl = request.GET.get("latl", -180)
lath = request.GET.get("lath", 180)
lonl = request.GET.get("lonl", -180)
lonh = request.GET.get("lonh", +180)
zoom = int(request.GET.get("zoom", -1))
loc_type = 0 if zoom >= 18 else 1 ;
stops = sched.stops_latlon(latl=latl, lath=lath, lonl=lonl, lonh=lonh, loc_type=loc_type)
l = [{'lat': s.stop_lat, 'lon': s.stop_lon, 'id': s.stop_id, 'nom': s.stop_name, 'loc_type':s.location_type} for s in stops]
return l
开发者ID:philippechataignon,项目名称:easytan,代码行数:11,代码来源:views.py
示例19: generate_sample_schedule
def generate_sample_schedule(self, business_forecast):
schedule = Schedule()
for i in business_forecast:
for j in range(0, int(i['frequency'] * i['schedule_type'])):
schedule.add_lesson(\
RandomWeeklyLesson(\
start_time_range=self.start_time_range,
day_of_week_range=self.day_of_week_range))
return schedule
开发者ID:Edderic,项目名称:udacity-machine-learning-nanodegree,代码行数:11,代码来源:models.py
示例20: loadScheduleBtn_clicked
def loadScheduleBtn_clicked(self):
"""Loads a schedule from file"""
schedule = Schedule()
filename = QFileDialog.getOpenFileName(self, "Load Schedule", exportsPath, "Schedule Files (*.sched)")
if filename is not None and filename != "":
try:
schedule.load(filename)
dialog = ScheduleDialog(schedule=schedule)
result = dialog.exec_()
if result == True:
pass
except Exception:
QMessageBox.critical(self, "Error", "Failed to load schedule.", QMessageBox.Ok)
开发者ID:diana134,项目名称:afs,代码行数:13,代码来源:mainwindow-old.py
注:本文中的schedule.Schedule类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论