for page in pages:
result = re.match(valid_filename, page)
if result != None:
- print('chooser: candidate page: "%s"' % page)
+ print(('chooser: candidate page: "%s"' % page))
if (result.group(3) != "none"):
freshness_requirement = int(result.group(3))
last_modified = int(os.path.getmtime(
os.path.join(constants.pages_dir, page)))
age = (now - last_modified)
if (age > freshness_requirement):
- print ('"%s" is too old.' % page)
+ print(('"%s" is too old.' % page))
continue
filenames.append(page)
return filenames
total_weight += weight
if (total_weight <= 0):
- raise(error("No valid candidate pages found!"))
+ raise error
while True:
pick = random.randrange(0, total_weight - 1)
so_far = 0
- for x in xrange(0, len(weights)):
+ for x in range(0, len(weights)):
so_far += weights[x]
if (so_far > pick and
self.pages[x] != self.last_choice):
# First try to satisfy from the page queue
if (len(self.page_queue) > 0):
- print "Pulling page from queue"
+ print("Pulling page from queue")
page = None
priority = None
for t in self.page_queue:
self.pages = self.get_page_list()
if len(self.pages) == 0:
- raise(error("No pages!"))
+ raise error
if (self.current >= len(self.pages)):
self.current = 0