Commit 06c11d4772fa9cb27a5ba06476c9daf72daa2f39

Authored by Gust
1 parent 5f51339e

Add interface for data importation for proxies

-Proxies utilizes the data_api.py fetchData() to expecify how to import
their data into the colab database
-Gitlab need to add the variable auth_token to colab.yml to have the
permission of acces to the gitlabAPI data

Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
Signed-off-by: Charles Oliveira <18oliveira.charles@gmail.com>
Signed-off-by: Carlos Oliveira <carlospecter@gmail.com>
colab/proxy/gitlab/data_api.py
1   -
2 1 import json
3 2 import urllib
4 3 import urllib2
... ...
colab/proxy/gitlab/models.py
1 1 from django.db import models
  2 +from django.conf import settings
  3 +from colab.accounts.models import User
2 4  
3 5  
4 6 class GitlabProject(models.Model):
... ...
colab/proxy/proxybase/__init__.py 0 → 100644
colab/proxy/proxybase/management/commands/__init__.py 0 → 100644
... ... @@ -0,0 +1 @@
  1 +__init__.py
0 2 \ No newline at end of file
... ...
colab/proxy/proxybase/management/commands/import_proxy_data.py 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +#!/usr/bin/env python
  2 +
  3 +import colab
  4 +from django.core.management.base import BaseCommand
  5 +from colab.super_archives.models import Message
  6 +from django.conf import settings
  7 +modules = [ i for i in settings.INSTALLED_APPS if i.startswith("colab.proxy.") ]
  8 +for module in modules:
  9 + module += ".data_api"
  10 + __import__(module, locals(), globals())
  11 +
  12 +class Command(BaseCommand):
  13 + help = "Import proxy data into colab database"
  14 +
  15 + def handle(self, *args, **kwargs):
  16 + print "Executing extraction command..."
  17 +
  18 + for module in modules:
  19 + extractionClassname = module + ".data_api." + module.split('.')[-1].title() + "DataAPI"
  20 + api = eval(extractionClassname)()
  21 + api.fetchData()
... ...
colab/proxy/proxybase/proxy_data_api.py 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +
  2 +class ProxyDataAPI():
  3 +
  4 +
  5 + def fetchData(self):
  6 + raise NotImplementedError('fetchData not yet implemented')
0 7 \ No newline at end of file
... ...
colab/settings.py
... ... @@ -321,8 +321,9 @@ if FEEDZILLA_ENABLED:
321 321 'common',
322 322 )
323 323  
324   -PROXIED_APPS = locals().get('PROXIED_APPS') or {}
325 324 BROWSERID_ENABLED = locals().get('BROWSERID_ENABLED') or False
326 325  
  326 +PROXIED_APPS = locals().get('PROXIED_APPS') or {}
  327 +
327 328 for app_label in PROXIED_APPS.keys():
328 329 INSTALLED_APPS += ('colab.proxy.{}'.format(app_label),)
... ...