Exemplo n.º 1
0
def rpc_unwatch(request):
  groups = request.POST.get('group', [])
  if not isinstance(groups, (list, tuple)):
    groups = [ groups ]
  for group in groups:
    Group.update(watch=False).where(Group.name == group).execute()
  return ''
Exemplo n.º 2
0
def get_groups(request):
  query = request.GET.get('query', '')
  watched = request.GET.get('watched', '')
  tqx = parse_tqx(request.GET.get('tqx', ''))
  tq = parse_tq(request.GET.get('tq', ''))

  select = Group.select()
  select = select.limit(tq.get('limit', 1))
  select = select.offset(tq.get('offset', 0))
  select = select.order_by(Group.name)
  if query:
    select = select.where(Group.name % ('*%s*' % query))
  if watched:
    select = select.where(Group.watch == True)

  dt = gviz.DataTable({
      'name': ('string', 'Name'),
      'watch': ('boolean', 'Watched')
      })
  dt_order = ['watch', 'name']
  dt.LoadData( g._data for g in select )
  gviz_json = dt.ToJSonResponse(req_id=tqx.get('reqId', 0),
                                columns_order=dt_order)

  return itty.Response(gviz_json, content_type='application/json')
Exemplo n.º 3
0
def get_state(request):
  data = {
      'jobs': IDXR.task_queue.qsize(),
      'articles': Article.select().count(),
      'groups': Group.select().count()
  }
  return itty.Response(json.dumps(data), content_type='application/json')
Exemplo n.º 4
0
  def __init__(self, config_file='defaults.cfg'):
    self.config = ConfigParser.SafeConfigParser()
    self.config.readfp(open(config_file))

    cache.database.init(self.config.get('indexer', 'cache_file'))
    Group.create_table(True)
    Article.create_table(True)

    max_nntp = self.config.getint('indexer', 'max_connections')
    self.nntp_semaphore = threading.BoundedSemaphore(max_nntp)

    max_task = 5
    self.task_queue = Queue()
    self.task_runners = []
    for i in xrange(max_task):
      runner = threading.Thread(target=self.task_runner)
      runner.daemon = True
      self.task_runners.append(runner)
      runner.start()
Exemplo n.º 5
0
 def update_watched(self, count=1000):
   for group in Group.watched():
     LOG.debug(group)
     self.get_last(group.name, count)
Exemplo n.º 6
0
 def _build_group_list(self, all=False):
   with self.nntp_connection as nntp:
     resp, groups = nntp.list()
   Group.add_from_nntplib(groups)