<commit_before>#!/usr/bin/env python26

#
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
#

import time, ConfigParser
import pymongo

# read in config.
config = ConfigParser.ConfigParser()
config.read("cssbot.cfg")

# setup db connection
mongo = pymongo.Connection()
db = mongo[config.get("mongo", "db_name")]
collection = db[config.get("mongo", "collection_posts")]

# spin.
for thread in collection.find({'solved':'N'}).sort('next_check', pymongo.ASCENDING):
   now = time.time()
   when = thread['next_check']
   if when < now:
      when = "+"
   elif when < (now+60):
      when = "%ds" % ((when-now))
   elif when < (now+3600):
      when = "%dm" % ((when-now)/60)
   elif when < (now+86400):
      when = "%.1fh" % ((when-now)/3600)
   else:
      when = "%.1fd" % ((when-now)/86400)

   print "%s\t%s\t%s" % (when, thread['id'], (thread['title']).replace('\n', ' '))


<commit_msg>catch io error during execution to a pipe<commit_after>#!/usr/bin/env python26

#
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
#

import sys, time, ConfigParser
import pymongo

# read in config.
config = ConfigParser.ConfigParser()
config.read("cssbot.cfg")

# setup db connection
mongo = pymongo.Connection()
db = mongo[config.get("mongo", "db_name")]
collection = db[config.get("mongo", "collection_posts")]

# spin.
try:
   for thread in collection.find({'solved':'N'}).sort('next_check', pymongo.ASCENDING):
      now = time.time()
      when = thread['next_check']
      if when < now:
         when = "+"
      elif when < (now+60):
         when = "%ds" % ((when-now))
      elif when < (now+3600):
         when = "%dm" % ((when-now)/60)
      elif when < (now+86400):
         when = "%.1fh" % ((when-now)/3600)
      else:
         when = "%.1fd" % ((when-now)/86400)

      print "%s\t%s\t%s" % (when, thread['id'], (thread['title']).replace('\n', ' '))
except IOError, e:
   sys.exit()



{'fraction_non_alphanumeric': 0.19471276054905948, 'fraction_numerical': 0.026436197254702594, 'mean_word_length': 3.3157894736842106, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7608204', 'n_tokens_mistral': 737, 'n_tokens_neox': 701, 'n_words': 155}