Пример #1
0
    def put(self, id):

        redis = datastore.get_datastore()
        akey = "activity:" + str(id)
        activity = pickle.loads(redis.hget('activitieshash', akey))

        print(activity)
        inputvalues = request.get_json(force=True)

        print(inputvalues)
        for k, v in inputvalues.iteritems():
            activity[k] = v

        akey = "activity:" + str(activity['id'])
        position = activity['id']

        redis.hset('activitieshash', akey, pickle.dumps(activity))

        if (activity['state'] == "FINISHED"):
            redis.zrem('sortet-activities:notfinished', akey)
            redis.zadd('sortet-activities:finished', position, akey)
        else:
            redis.zrem('sortet-activities:finished', akey)
            redis.zadd('sortet-activities:notfinished', position, akey)

        if len(activity) == 0:
            abort(404)
        return activity, 201
Пример #2
0
    def post(self, id):
        redis = datastore.get_datastore()

        log = request.get_json(force=True)
        akey =  akey = "activity:" + str(id) + ":logs"
        redis.lpush (akey, pickle.dumps(log) )
        # get a dict from the response
        log = request.get_json(force=True)
        return log, 201
Пример #3
0
 def delete(self, id):
     redis = datastore.get_datastore()
     akey = "activity:" + str(id)
     l = redis.hdel('activitieshash', akey)
     logkey = "activity:" + str(id) + ":logs"
     ll = redis.lrem(logkey)
     if l == 0:
         abort(404)
     return {'result': True}
Пример #4
0
    def get(self, id):

        redis = datastore.get_datastore()
        akey = "activity:" + str(id)

        activity = {}
        activityencoded = redis.hget('activitieshash', akey)
        if activityencoded != None: activity = pickle.loads(activityencoded)

        if len(activity) == 0:
            abort(404)

        return activity, 200
Пример #5
0
    def get(self, id):
        redis = datastore.get_datastore()

        start = 0
        end = -1
        if 'offset' in request.args:  start = int( request.args.get('offset'))
        if 'limit' in request.args:   end = start + int(request.args.get('limit')) -1

        akey = akey = "activity:" + str(id) + ":logs"
        logsEncoded =  redis.lrange (akey, start, end)
        allLogs = []

        for l in logsEncoded:
            allLogs.append (pickle.loads(l))

        limit = end - start + 1
        resultset = {"count": len(allLogs), "offset": start, "limit": limit}
        fullresponse = {"metadata": resultset, "content": allLogs}
        return fullresponse, 200
Пример #6
0
    def post(self):
        redis = datastore.get_datastore()

        # get a dict from the response
        activity = request.get_json(force=True)

        position = int(redis.get('activityindex'))
        redis.incr('activityindex', 1)
        activity['id'] = str(position)

        akey = "activity:" + str(activity['id'])
        redis.hset('activitieshash', akey, pickle.dumps(activity))

        redis.zadd('sortet-activities:all', position, akey)
        if (activity['state'] == "FINISHED"):
            redis.zadd('sortet-activities:finished', position, akey)
        else:
            redis.zadd('sortet-activities:notfinished', position, akey)
        return activity, 201
Пример #7
0
def show():

    redis = datastore.get_datastore()

    repokeys = redis.zrangebylex('repos', '-', '+')
    allr = ''

    g = Github("f87f5f9e252e348b01b65018a6b2be49d88f12e1")

    #access_token = 'BLAH'
    #gh = Github(access_token, base_url='https://myorg.github.com/api/v3')
    #gh.get_user().name

    #class github.MainClass.Github(login_or_token=None, password=None, base_url='https://api.github.com', timeout=10, client_id=None, client_secret=None, user_agent='PyGithub/Python', per_page=30)¶

    user = g.get_user()


    repos = user.get_repos()
    for k in repokeys:
        name = redis.hget('repohash', k)
        if name.startswith("bibbox/app-"):
            try:
                r = g.get_repo(name)
#                file = r.get_file_contents("appinfo.json")
#                print("READ ", file.url)
#               desrc = json.loads( ur.urlopen(file.url).read().decode('utf8') )
#               print(desrc)

            except ZeroDivisionError as e:
                print("no appinfo")

    for k in repokeys:
        name = redis.hget('repohash', k)
        if name.startswith("bibbox/app-"):
            allr = allr + "<h3>" + str(name) + "</h3>"
        if name.startswith("sys-"):
            allr = allr + "<h3>" + str(name) + "</h3>"

    return allr
Пример #8
0
    def get(self):
        redis = datastore.get_datastore()
        finished = request.args.get('finished')

        start = 0
        end = -1
        if 'offset' in request.args: start = int(request.args.get('offset'))
        if 'limit' in request.args:
            end = start + int(request.args.get('limit')) - 1

        cAll = redis.zcount('sortet-activities:all', '-inf', '+inf')
        cFinished = redis.zcount('sortet-activities:finished', '-inf', '+inf')
        cNotFinished = cAll - cFinished

        if (finished == 'true'):
            actKeys = redis.zrevrange('sortet-activities:finished', start, end)
            total = cFinished
        else:
            actKeys = redis.zrevrange('sortet-activities:all', start, end)
            total = cAll

        allActivities = []
        for k in actKeys:
            activityencoded = redis.hget('activitieshash', k)
            if activityencoded != None:
                activity = pickle.loads(activityencoded)
                activity['url'] = request.url + "/" + str(activity['id'])
                allActivities.append(activity)

        limit = end - start + 1
        resultset = {
            "count": len(actKeys),
            "total": total,
            "offset": start,
            "limit": limit,
            "pending": cNotFinished
        }
        fullresponse = {"metadata": resultset, "content": allActivities}
        return fullresponse, 200
Пример #9
0
 def get(self):
     redis = datastore.get_datastore()
     redis.flushall();
     redis.set ('activityindex', "0")
     return "SUCESS", 200