Esempio n. 1
0
def getIconFileIOS4(dirApp, zfile, path, plist):
    h.logm("DBG", 5, "ACTION " + h.getcalled())

    if not 'CFCommodityIconFiles' in plist:
        h.logm("ERR", 5, "no CFCommodityIconFiles in plist")
        return None

    commodityIconFiles = plist['CFCommodityIconFiles']

    for commodityIconName in commodityIconFiles:
        iconapp = dirApp + commodityIconName
        if iconapp in zfile.namelist():
            zfile.extract(iconapp, path=path)

            commodityIconFile = os.path.join(path, dirApp, commodityIconName)
            if os.path.exists(commodityIconFile):
                break
            else:
                h.logm(
                    "ERR", 5, "commodityIconFile " + commodityIconFile +
                    " does not exist in BREAD")
                commodityIconFile = None

    if not commodityIconFile:
        h.logm("ERR", 5, "commodityIconFile does not exist in BREAD")
    else:
        h.logm("INF", 5,
               "commodityIconFile in BREAD!, using " + commodityIconFile)

    return commodityIconFile
Esempio n. 2
0
    def userDelete(self, id=None):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        if request.method != 'DELETE':
            h.logm("ERR",5,"EXCEPTION, method is " + request.method);
            return self.jsonErrorResponse(500, "adm/user action does only allow DELETE request method");
        if not id:
            h.logm("ERR",5,"EXCEPTION, parameter missing" + request.method);
            return self.jsonErrorResponse(407, "adm/user/id, missing parameter id");

        userid = str(id);
        h.logm("DBG",5,"request w/ userid=" + userid);

        db = self._py_object.app_globals.db;

        user = None;

        try:
            user = db.users.find_one({'_id': ObjectId(userid)});
        except:
            return self.jsonErrorResponse(404, "Invalid Mongo DB User Id {'_id' : " + userid + '}');
        else:
            if not user:
                return self.jsonErrorResponse(404, "Invalid user id " + userid);

            h.logm("INF",5,"found user: "******"$pull" : {"users" : (ObjectId(userid))}});
        db.users.remove({'_id': ObjectId(userid)});

        responseDict = { "oid" : str(user['_id']) };

        return self.jsonResponse(responseDict);
Esempio n. 3
0
def getIconFileIOS4(dirApp, zfile, path, plist):
    h.logm("DBG",5,"ACTION "+ h.getcalled());

    if not 'CFCommodityIconFiles' in plist:
        h.logm("ERR",5,"no CFCommodityIconFiles in plist");
        return None;

    commodityIconFiles = plist['CFCommodityIconFiles'];

    for commodityIconName in commodityIconFiles:
        iconapp = dirApp + commodityIconName
        if iconapp in zfile.namelist():
            zfile.extract(iconapp, path=path);

            commodityIconFile = os.path.join(path, dirApp, commodityIconName);
            if os.path.exists(commodityIconFile):
                break;
            else:
                h.logm("ERR",5,"commodityIconFile "+ commodityIconFile + " does not exist in BREAD");
                commodityIconFile = None;

    if not commodityIconFile:
        h.logm("ERR",5,"commodityIconFile does not exist in BREAD");
    else:
        h.logm("INF",5,"commodityIconFile in BREAD!, using " + commodityIconFile);

    return commodityIconFile;
Esempio n. 4
0
def buildfilepath(appid, breadid=None):
    h.logm("DBG",5,"ACTION "+ h.getcalled());

    assert config['app_conf']['permanent_store'];
    filepath = os.path.join(config['app_conf']['permanent_store'], buildfilename(appid, breadid));

    return filepath;
Esempio n. 5
0
    def index(self):
        h.logm("DBG", 5, "ACTION " + h.getcalled())
        h.logm("INF", 5, "params " + str(request.params))

        self.buildInformation()

        return render('/admingroup.mako')
Esempio n. 6
0
def createdir(groupid):
    h.logm("DBG",5,"ACTION "+ h.getcalled());
    assert config['app_conf']['permanent_store'];
    dirpath = os.path.join(config['app_conf']['permanent_store'], groupid);
    if not os.path.exists(filepath):
        os.mkdir(dirpath);
    return dirpath;
Esempio n. 7
0
    def index(self):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        h.logm("INF",5,"params "+ str(request.params));

        self.buildInformation();

        return render('/admingroup.mako');
Esempio n. 8
0
    def applicationGet(self, id=None):
        h.logm("DBG", 5, "ACTION " + h.getcalled())
        if request.method != 'GET':
            h.logm("ERR", 5, "EXCEPTION, method is " + request.method)
            return self.jsonErrorResponse(
                500, "adm/applications does only allow GET request method")
        if not id:
            h.logm("ERR", 5, "EXCEPTION, parameter missing" + request.method)
            return self.jsonErrorResponse(
                407, "adm/application/id missing parameter id")

        applicationid = str(id)

        db = self._py_object.app_globals.db
        try:
            application = db.applications.find_one(
                {'_id': ObjectId(applicationid)})
        except:
            return self.jsonErrorResponse(
                404, "Invalid Mongo DB Application Id {'_id' : " +
                applicationid + '}')
        else:
            if not application:
                return self.jsonErrorResponse(
                    404, "Invalid application id " + applicationid)

        return self.jsonResponse(
            Application(application).encodeWithBreadEntries())
Esempio n. 9
0
    def groupDelete(self, id=None):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        if request.method != 'DELETE':
            h.logm("ERR",5,"EXCEPTION, method is " + request.method);
            return self.jsonErrorResponse(500, "adm/group action does only allow DELETE request method");
        if not id:
            h.logm("ERR",5,"EXCEPTION, parameter missing" + request.method);
            return self.jsonErrorResponse(407, "adm/group/id, missing parameter id");

        groupid = str(id);
        h.logm("DBG",5,"request w/ groupid=" + groupid);

        db = self._py_object.app_globals.db;

        group = None;

        try:
            group = db.groups.find_one({'_id': ObjectId(groupid)});
        except:
            return self.jsonErrorResponse(404, "Invalid Mongo DB Group Id {'_id' : " + groupid + '}');
        else:
            if not group:
                return self.jsonErrorResponse(404, "Invalid group id " + groupid);

            h.logm("INF",5,"found group: " + str(group));

        db.groups.remove({'_id': ObjectId(groupid)});

        responseDict = { "oid" : str(group['_id']) };

        return self.jsonResponse(responseDict);
Esempio n. 10
0
    def userPost(self):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        if request.method != 'POST':
            h.logm("ERR",5,"EXCEPTION, method is " + request.method);
            return self.jsonErrorResponse(500, "adm/user action does only allow POST request method");

        h.logm("DBG",5,"request.POST body: " + request.body);

        userSchema = json.loads(request.body);
        user = User(userSchema);

        db = self._py_object.app_globals.db;
        if db.users.find_one({'name': user.name}):
            h.logm("INF",5,"user already exist: " + str(user.encode()));
            return self.jsonErrorResponse(405, "user already exist with this name: " + str(user.encode()));

        db = self._py_object.app_globals.db;
        if db.users.find_one({'email': user.email}):
            h.logm("INF",5,"user already exist: " + str(user.encode()));
            return self.jsonErrorResponse(405, "user already exist with this email: " + str(user.encode()));

        h.logm("INF",5,"trying to create user: "******"Cannot create user: "******"oid" : str(userid) };

        return self.jsonResponse(responseDict);
Esempio n. 11
0
    def removeUser(self):
        h.logm("DBG", 5, "ACTION " + h.getcalled())
        h.logm("DBG", 5, "params " + str(request.params))

        db = self._py_object.app_globals.db

        userid = 0
        for (k, v) in request.params.iteritems():
            if v == '-':
                userid = k
                break

        db.groups.update({}, {"$pull": {
            "users": (ObjectId(userid))
        }})

        user = db.users.find_one({'_id': ObjectId(userid)})

        db.users.remove({'_id': ObjectId(userid)})

        session[
            'message_admingroup'] = 'Congratulations: REMOVED user [' + user[
                'name'] + ']!'

        session.save()

        self.buildInformation()
        return render('/admingroup.mako')
Esempio n. 12
0
    def userPut(self, id=None):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        if request.method != 'PUT':
            h.logm("ERR",5,"EXCEPTION, method is " + request.method);
            return self.jsonErrorResponse(500, "adm/user action does only allow PUT request method");
        if not id:
            h.logm("ERR",5,"EXCEPTION, parameter missing" + request.method);
            return self.jsonErrorResponse(407, "adm/user/id, missing parameter id");

        userid = str(id);
        h.logm("DBG",5,"request.POST body: " + str(request.body) + ", userid=" + userid);

        userSchema = json.loads(request.body);

        db = self._py_object.app_globals.db;

        user = None;

        try:
            user = db.users.find_one({'_id': ObjectId(userid)});
        except:
            return self.jsonErrorResponse(404, "Invalid Mongo DB User Id {'_id' : " + userid + '}');
        else:
            if not user:
                return self.jsonErrorResponse(404, "Invalid user id " + userid);

            h.logm("INF",5,"found user: "******"INF",5,"user name is (unique) and already exist: " + str(userWithName));
                return self.jsonErrorResponse(405, "user name is (unique) and already exist w/another object id: " + str(userWithName));

        if 'email' in userSchema:
            userWithEmail = db.users.find_one({'email': userSchema['email']});
            if userWithEmail and str(userWithEmail['_id']) != userid:
                h.logm("INF",5,"user email is (unique) and already exist: " + str(userWithEmail));
                return self.jsonErrorResponse(405, "user email is (unique) and already exist w/another object id: " + str(userWithEmail));

        h.logm("INF",5,"trying to update user: "******"_id" : user['_id']}, {"$set" : {"name" : userSchema['name']}});

        if 'email' in userSchema:
            db.users.update({"_id" : user['_id']}, {"$set" : {"email" : userSchema['email']}});

        if 'apples' in userSchema:
            for apple in user['apples']:
                db.users.update({"_id" : user['_id']}, {"$pull" : {"apples" : apple}});
            for apple in userSchema['apples']:
                db.users.update({"_id" : user['_id']}, {"$push" : {"apples" : str(apple)}});

        responseDict = { "oid" : str(user['_id']) };

        return self.jsonResponse(responseDict);
Esempio n. 13
0
 def groupApplication(self, id, id2):
     h.logm("DBG",5,"ACTION "+ h.getcalled());
     if request.method == 'POST':
         return self.groupAddApplication(id,id2);
     elif request.method == 'DELETE':
         return self.groupDeleteApplication(id,id2);
     else:
         return self.jsonErrorResponse(500, "adm/groupApplication/{id}/{id2} action only allows POST/DELETE request method. Request: " + request.method);
Esempio n. 14
0
def buildfilename(appid, breadid=None):
    h.logm("DBG",5,"ACTION "+ h.getcalled());

    if breadid:
        filename = appid + "_" + breadid;
    else:
        filename = appid;

    return filename;
Esempio n. 15
0
 def application(self, id=None):
     h.logm("DBG",5,"ACTION "+ h.getcalled());
     if request.method == 'GET':
         return self.applicationGet(id);
     elif request.method == 'DELETE':
         return self.applicationDelete(id);
     else:
         h.logm("ERR",5,"EXCEPTION, method is " + request.method);
         return self.jsonErrorResponse(500, "adm/application action only allows GET/DELETE request method");
Esempio n. 16
0
def getfilepath(appid, breadid=None):
    h.logm("DBG",5,"ACTION "+ h.getcalled());

    filepath = buildfilepath(appid, breadid);

    if not os.path.exists(filepath):
        h.logm("DBG",5, 'file ' + filepath + ' does not exist');
        return None;

    return filepath;
Esempio n. 17
0
def getfileUsingResponse(appid, breadid, response):
    h.logm("DBG",5,"ACTION "+ h.getcalled());

    filename = getfilepath(appid, breadid);

    with open(filename, 'rb') as fileptr:
        shutil.copyfileobj(fileptr, response)

    h.logm("INF",5, 'filename %s' % filename);
    fileptr.close()
Esempio n. 18
0
    def index(self):
        h.logm("DBG", 5, "ACTION " + h.getcalled())

        db = self._py_object.app_globals.db
        c.users = db.users.find()

        c.message = ''
        c.email = ''
        c.logged = True
        return render('/signup.mako')
Esempio n. 19
0
    def index(self):
        h.logm("DBG",5,"ACTION "+ h.getcalled());

        db = self._py_object.app_globals.db;
        c.users = db.users.find();

        c.message = '';
        c.email = '';
        c.logged = True;
        return render('/signup.mako')
Esempio n. 20
0
 def groupApplication(self, id, id2):
     h.logm("DBG", 5, "ACTION " + h.getcalled())
     if request.method == 'POST':
         return self.groupAddApplication(id, id2)
     elif request.method == 'DELETE':
         return self.groupDeleteApplication(id, id2)
     else:
         return self.jsonErrorResponse(
             500,
             "adm/groupApplication/{id}/{id2} action only allows POST/DELETE request method. Request: "
             + request.method)
Esempio n. 21
0
 def application(self, id=None):
     h.logm("DBG", 5, "ACTION " + h.getcalled())
     if request.method == 'GET':
         return self.applicationGet(id)
     elif request.method == 'DELETE':
         return self.applicationDelete(id)
     else:
         h.logm("ERR", 5, "EXCEPTION, method is " + request.method)
         return self.jsonErrorResponse(
             500,
             "adm/application action only allows GET/DELETE request method")
Esempio n. 22
0
 def group(self, id=None, action2=None, id2=None):
     h.logm("DBG",5,"ACTION "+ h.getcalled());
     if request.method == 'POST':
         return self.groupPost();
     elif request.method == 'PUT':
         return self.groupPut(id);
     elif request.method == 'DELETE':
         return self.groupDelete(id);
     else:
         h.logm("ERR",5,"EXCEPTION, method is " + request.method);
         return self.jsonErrorResponse(500, "adm/group action does only allow POST/PUT/DELETE request methods");
Esempio n. 23
0
    def applications(self):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        if request.method != 'GET':
            h.logm("ERR",5,"EXCEPTION, method is " + request.method);
            return self.jsonErrorResponse(500, "adm/applications does only allow GET request method");

        db = self._py_object.app_globals.db;
        applications = db.applications.find();
        responseArray = [];
        for application in applications:
            responseArray.append(Application(application).encodeWithBreadEntries());

        return self.jsonResponse(responseArray);
Esempio n. 24
0
def createfile(filepointer, appid, breadid = None):
    h.logm("DBG",5,"ACTION "+ h.getcalled());
    
    filepath = buildfilepath(appid, breadid);
    h.logm("DBG",5,"filepath "+ filepath);

    permanent_file = open(filepath, 'wb');
    filepointer.file.seek(0);
    shutil.copyfileobj(filepointer.file, permanent_file);
    filepointer.file.close();
    permanent_file.close();

    return (filepath, os.path.getsize(filepath));
Esempio n. 25
0
def getfile_(appid, breadid=None):
    h.logm("DBG",5,"ACTION "+ h.getcalled());

    filename = getfilepath(appid, breadid);

    h.logm("INF",5, 'filename %s' % filename);
    headers = [('Content-Disposition', 'attachment; filename=\"' + filename + '\"'),
        ('Content-Type', 'application/octet-stream'),
        ('Content-Length', str(os.path.getsize(filename)))];

    h.logm("INF",5, 'headers ' + str(headers));
#    return FileApp(filename, headers=headers);
    return FileApp(filename, headers=headers)
Esempio n. 26
0
    def groups(self):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        if request.method != 'GET':
            h.logm("ERR",5,"EXCEPTION, method is " + request.method);
            return self.jsonErrorResponse(500, "adm/groups does only allow GET request method");

        db = self._py_object.app_globals.db;
        groups = db.groups.find();
        responseArray = [];
        for group in groups:
            responseArray.append(Group(group).encode());

        return self.jsonResponse(responseArray);
Esempio n. 27
0
    def users(self):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        if request.method != 'GET':
            h.logm("ERR",5,"EXCEPTION, method is " + request.method);
            return self.jsonErrorResponse(500, "adm/users does only allow GET request method");

        db = self._py_object.app_globals.db;
        users = db.users.find();
        responseArray = [];
        for user in users:
            responseArray.append(User(user).encode());

        return self.jsonResponse(responseArray);
Esempio n. 28
0
    def groupDeleteUser(self, id, id2):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        if request.method != 'DELETE':
            h.logm("ERR",5,"EXCEPTION, method is " + request.method);
            return self.jsonErrorResponse(500, "adm/groupUser/{id}/{id2} action does only allow DELETE request method. Request: " + request.method);

        if not id:
            h.logm("ERR",5,"EXCEPTION, parameter missing" + request.method);
            return self.jsonErrorResponse(407, "adm/group/id/user/id2, missing parameter id for group.");
        
        groupid = str(id);

        if not id2:
            h.logm("ERR",5,"EXCEPTION, parameter missing" + request.method);
            return self.jsonErrorResponse(407, "adm/group/id/user/id2, missing parameter id2 for user.");
        
        userid = str(id2);

        db = self._py_object.app_globals.db;
        try:
            group = db.groups.find_one({'_id': ObjectId(groupid)});
        except:
            return self.jsonErrorResponse(404, "Invalid Mongo DB Group Id {'_id' : " + groupid + '}');
        else:
            if not group:
                return self.jsonErrorResponse(404, "Invalid group id " + groupid);

            h.logm("INF",5,"found group: " + str(group));


        if userid not in str(group['users']):
            return self.jsonErrorResponse(405, "userid " + userid + " does not exist in group: " + str(group));

        try:
            user = db.users.find_one({'_id': ObjectId(userid)});
        except:
            return self.jsonErrorResponse(404, "Invalid Mongo DB User Id {'_id' : " + userid + '}');
        else:
            if not user:
                return self.jsonErrorResponse(404, "Invalid user id " + userid);

            h.logm("INF",5,"found user: "******"_id" : group['_id']}, {"$pull" : {"users" : ObjectId(userid)}});

        responseObject = {};
        responseObject["groupOid"] = groupid;
        responseObject["userOid"] = userid;

        return self.jsonResponse(responseObject);
Esempio n. 29
0
    def groupDeleteApplication(self, id, id2):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        if request.method != 'DELETE':
            h.logm("ERR",5,"EXCEPTION, method is " + request.method);
            return self.jsonErrorResponse(500, "adm/groupApplication/{id}/{id2} action does only allow DELETE request method. Request: " + request.method);

        if not id:
            h.logm("ERR",5,"EXCEPTION, parameter missing" + request.method);
            return self.jsonErrorResponse(407, "adm/group/id/application/id2, missing parameter id for group.");
        
        groupid = str(id);

        if not id2:
            h.logm("ERR",5,"EXCEPTION, parameter missing" + request.method);
            return self.jsonErrorResponse(407, "adm/group/id/application/id2, missing parameter id2 for application.");
        
        applicationid = str(id2);

        db = self._py_object.app_globals.db;
        try:
            group = db.groups.find_one({'_id': ObjectId(groupid)});
        except:
            return self.jsonErrorResponse(404, "Invalid Mongo DB Group Id {'_id' : " + groupid + '}');
        else:
            if not group:
                return self.jsonErrorResponse(404, "Invalid group id " + groupid);

            h.logm("INF",5,"found group: " + str(group));


        if applicationid not in str(group['applications']):
            return self.jsonErrorResponse(405, "applicationid " + applicationid + " does not exist in group: " + str(group));

        try:
            application = db.applications.find_one({'_id': ObjectId(applicationid)});
        except:
            return self.jsonErrorResponse(404, "Invalid Mongo DB Application Id {'_id' : " + applicationid + '}');
        else:
            if not application:
                return self.jsonErrorResponse(404, "Invalid application id " + applicationid);

            h.logm("INF",5,"found application: " + str(application));


        db.groups.update({"_id" : group['_id']}, {"$pull" : {"applications" : ObjectId(applicationid)}});

        responseObject = {};
        responseObject["groupOid"] = groupid;
        responseObject["applicationOid"] = applicationid;

        return self.jsonResponse(responseObject);
Esempio n. 30
0
 def group(self, id=None, action2=None, id2=None):
     h.logm("DBG", 5, "ACTION " + h.getcalled())
     if request.method == 'POST':
         return self.groupPost()
     elif request.method == 'PUT':
         return self.groupPut(id)
     elif request.method == 'DELETE':
         return self.groupDelete(id)
     else:
         h.logm("ERR", 5, "EXCEPTION, method is " + request.method)
         return self.jsonErrorResponse(
             500,
             "adm/group action does only allow POST/PUT/DELETE request methods"
         )
Esempio n. 31
0
    def groups(self):
        h.logm("DBG", 5, "ACTION " + h.getcalled())
        if request.method != 'GET':
            h.logm("ERR", 5, "EXCEPTION, method is " + request.method)
            return self.jsonErrorResponse(
                500, "adm/groups does only allow GET request method")

        db = self._py_object.app_globals.db
        groups = db.groups.find()
        responseArray = []
        for group in groups:
            responseArray.append(Group(group).encode())

        return self.jsonResponse(responseArray)
Esempio n. 32
0
    def users(self):
        h.logm("DBG", 5, "ACTION " + h.getcalled())
        if request.method != 'GET':
            h.logm("ERR", 5, "EXCEPTION, method is " + request.method)
            return self.jsonErrorResponse(
                500, "adm/users does only allow GET request method")

        db = self._py_object.app_globals.db
        users = db.users.find()
        responseArray = []
        for user in users:
            responseArray.append(User(user).encode())

        return self.jsonResponse(responseArray)
Esempio n. 33
0
    def removeGroup(self):
        h.logm("DBG", 5, "ACTION " + h.getcalled())

        params = request.params
        h.logm("DBG", 5, "params " + str(params))

        schema = Validator.FormRemoveGroupValidator()
        try:
            form_result = schema.to_python(request.params)

        except formencode.Invalid, error:
            c.message = h.literal(htmlfill.escapenl_formatter(error))
            session['message'] = c.message
            session.save()
Esempio n. 34
0
    def removeGroup(self):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        
        params = request.params;
        h.logm("DBG",5,"params "+ str(params));

        schema = Validator.FormRemoveGroupValidator();
        try:
            form_result = schema.to_python(request.params);

        except formencode.Invalid, error:
            c.message = h.literal(htmlfill.escapenl_formatter(error));
            session['message'] = c.message;
            session.save();
Esempio n. 35
0
    def applications(self):
        h.logm("DBG", 5, "ACTION " + h.getcalled())
        if request.method != 'GET':
            h.logm("ERR", 5, "EXCEPTION, method is " + request.method)
            return self.jsonErrorResponse(
                500, "adm/applications does only allow GET request method")

        db = self._py_object.app_globals.db
        applications = db.applications.find()
        responseArray = []
        for application in applications:
            responseArray.append(
                Application(application).encodeWithBreadEntries())

        return self.jsonResponse(responseArray)
Esempio n. 36
0
    def applicationDelete(self, id=None):
        h.logm("DBG", 5, "ACTION " + h.getcalled())
        if request.method != 'DELETE':
            h.logm("ERR", 5, "EXCEPTION, method is " + request.method)
            return self.jsonErrorResponse(
                500,
                "adm/application action does only allow DELETE request method")
        if not id:
            h.logm("ERR", 5, "EXCEPTION, parameter missing" + request.method)
            return self.jsonErrorResponse(
                407, "adm/application/id, missing parameter id")

        applicationid = str(id)
        h.logm("DBG", 5, "request w/ applicationid=" + applicationid)

        db = self._py_object.app_globals.db

        application = None

        try:
            application = db.applications.find_one(
                {'_id': ObjectId(applicationid)})
        except:
            return self.jsonErrorResponse(
                404, "Invalid Mongo DB Application Id {'_id' : " +
                applicationid + '}')
        else:
            if not application:
                return self.jsonErrorResponse(
                    404, "Invalid application id " + applicationid)

            h.logm("INF", 5, "found application: " + str(application))

        if 'breadEntries' in application:
            for breadEntry in application['breadEntries']:
                sfh.deletebread(str(applicationid), str(breadEntry['id']))

        db.groups.update(
            {}, {"$pull": {
                "applications": (ObjectId(applicationid))
            }})
        db.applications.remove({'_id': ObjectId(applicationid)})

        responseDict = {
            "oid": str(application['_id'])
        }

        return self.jsonResponse(responseDict)
Esempio n. 37
0
def createfilename(filename, appid, breadid = None):
    h.logm("DBG",5,"ACTION "+ h.getcalled());
    
    filepath = buildfilepath(appid, breadid);
    size = os.path.getsize(filename)

    permanent_file = open(filepath, 'wb');
    fileptr = open(filename, 'rb');
    if not fileptr:
        h.logm("DBG",5, 'cannot read file');
        return None;

    shutil.copyfileobj(fileptr, permanent_file);
    fileptr.close()
    permanent_file.close()
    return (filepath, size);
Esempio n. 38
0
def getIconFile(dirApp, zfile, path, plist):
    h.logm("DBG",5,"ACTION "+ h.getcalled());
    iconFile = getIconFileIOS4(dirApp, zfile, path, plist);
    if iconFile:
        return iconFile;

    iconFile = getIconFileIOS3(dirApp, zfile, path, plist);
    if iconFile:
        return iconFile;

    iconFile = getIconFileIOS5(dirApp, zfile, path, plist);
    if iconFile:
        return iconFile;

    h.logm("ERR",5,"no IconFile in bread");
    return None;
Esempio n. 39
0
def getIconFile(dirApp, zfile, path, plist):
    h.logm("DBG", 5, "ACTION " + h.getcalled())
    iconFile = getIconFileIOS4(dirApp, zfile, path, plist)
    if iconFile:
        return iconFile

    iconFile = getIconFileIOS3(dirApp, zfile, path, plist)
    if iconFile:
        return iconFile

    iconFile = getIconFileIOS5(dirApp, zfile, path, plist)
    if iconFile:
        return iconFile

    h.logm("ERR", 5, "no IconFile in bread")
    return None
Esempio n. 40
0
    def addUserToGroup(self):

        h.logm("DBG",5,"ACTION "+ h.getcalled());
        
        schema = Validator.FormAddUserValidator();
        try:
            form_result = schema.to_python(request.params);
            h.logm("DBG",5,"f r "+ str(request.params));
            h.logm("DBG",5,"TRY");

        except formencode.Invalid, error:
            h.logm("DBG",5,"EXCEPT");
            h.logm("ERR",5,"f r "+ str(request.params));
            c.message = h.literal(htmlfill.escapenl_formatter(error));
            session['message'] = c.message;
            session.save();
Esempio n. 41
0
    def addUserToGroup(self):

        h.logm("DBG", 5, "ACTION " + h.getcalled())

        schema = Validator.FormAddUserValidator()
        try:
            form_result = schema.to_python(request.params)
            h.logm("DBG", 5, "f r " + str(request.params))
            h.logm("DBG", 5, "TRY")

        except formencode.Invalid, error:
            h.logm("DBG", 5, "EXCEPT")
            h.logm("ERR", 5, "f r " + str(request.params))
            c.message = h.literal(htmlfill.escapenl_formatter(error))
            session['message'] = c.message
            session.save()
Esempio n. 42
0
def getIconFileIOS5(dirApp, zfile, path, plist):
    h.logm("DBG", 5, "ACTION " + h.getcalled())

    if not 'CFCommodityIcons' in plist:
        h.logm("ERR", 5, "no CFCommodityIcons in plist")
        return None

    commodityIconFileDict = plist['CFCommodityIcons']

    if 'CFCommodityPrimaryIcon' in commodityIconFileDict:
        commodityIconName = commodityIconFileDict['CFCommodityPrimaryIcon']

        iconapp = dirApp + commodityIconName
        if iconapp in zfile.namelist():
            zfile.extract(iconapp, path=path)

            commodityIconFile = os.path.join(path, dirApp, commodityIconName)

            if os.path.exists(commodityIconFile):
                return commodityIconFile
            else:
                commodityIconFile = None
    else:
        h.logm("ERR", 5, "no CFCommodityPrimaryIcon in plist")

    if 'UINewsstandIcon' in commodityIconFileDict:
        commodityIconName = commodityIconFileDict['UINewsstandIcon']

        iconapp = dirApp + commodityIconName
        if iconapp in zfile.namelist():
            zfile.extract(iconapp, path=path)

            commodityIconFile = os.path.join(path, commodityIconName)
            if os.path.exists(commodityIconFile):
                return commodityIconFile
            else:
                commodityIconFile = None
    else:
        h.logm("ERR", 5, "no UINewsstandIcon in plist")

    if not commodityIconFile:
        h.logm(
            "ERR", 5, "commodityIconFile (IOS5)" + commodityIconFile +
            " does not exist in BREAD")

    return None
Esempio n. 43
0
    def submit(self):
        h.logm("DBG", 5, "ACTION " + h.getcalled())

        db = self._py_object.app_globals.db
        c.users = db.users.find()
        c.email = ''
        c.logged = True
        c.message = ''
        schema = SignupValidator()
        try:
            form_result = schema.to_python(request.params)
            h.logm("DBG", 5, "f r " + str(request.params))

        except formencode.Invalid, error:
            h.logm("ERR", 5, "f r " + str(request.params))

            c.message = h.literal(htmlfill.escapenl_formatter(error))
            return render('/signup.mako')
Esempio n. 44
0
    def removeApple(self):
        h.logm("DBG", 5, "ACTION " + h.getcalled())
        h.logm("DBG", 5, "params " + str(request.params))

        db = self._py_object.app_globals.db

        schema = Validator.FormRemoveUserAppleValidator()
        try:
            form_result = schema.to_python(request.params)
            h.logm("DBG", 5, "f r " + str(request.params))
            h.logm("DBG", 5, "TRY")

        except formencode.Invalid, error:
            h.logm("DBG", 5, "EXCEPT")
            h.logm("ERR", 5, "f r " + str(request.params))
            c.message = h.literal(htmlfill.escapenl_formatter(error))
            session['message'] = c.message
            session.save()
Esempio n. 45
0
    def removeApple(self):
        h.logm("DBG",5,"ACTION "+ h.getcalled());
        h.logm("DBG",5,"params "+ str(request.params));
        
        db = self._py_object.app_globals.db;

        schema = Validator.FormRemoveUserAppleValidator();
        try:
            form_result = schema.to_python(request.params);
            h.logm("DBG",5,"f r "+ str(request.params));
            h.logm("DBG",5,"TRY");

        except formencode.Invalid, error:
            h.logm("DBG",5,"EXCEPT");
            h.logm("ERR",5,"f r "+ str(request.params));
            c.message = h.literal(htmlfill.escapenl_formatter(error));
            session['message'] = c.message;
            session.save();
Esempio n. 46
0
def getfile(appid, breadid=None):
    h.logm("DBG",5,"ACTION "+ h.getcalled());

    filename = getfilepath(appid, breadid);

    content_type = mimetypes.guess_type(filename);

    fileptr = open(filename, 'rb');
    if not fileptr:
        h.logm("DBG",5, 'cannot read file');
        return None;

    data = fileptr.read()
    h.logm("INF",5, 'filename %s data len %d' % (filename, len(data)));

    fileptr.close()

    return data;
Esempio n. 47
0
def getIconFileIOS5(dirApp, zfile, path, plist):
    h.logm("DBG",5,"ACTION "+ h.getcalled());

    if not 'CFCommodityIcons' in plist:
        h.logm("ERR",5,"no CFCommodityIcons in plist");
        return None;

    commodityIconFileDict = plist['CFCommodityIcons'];

    if 'CFCommodityPrimaryIcon' in commodityIconFileDict:
        commodityIconName = commodityIconFileDict['CFCommodityPrimaryIcon']

        iconapp = dirApp + commodityIconName
        if iconapp in zfile.namelist():
            zfile.extract(iconapp, path=path);

            commodityIconFile = os.path.join(path, dirApp, commodityIconName);

            if os.path.exists(commodityIconFile):
                return commodityIconFile;
            else:
                commodityIconFile = None;
    else:
        h.logm("ERR",5,"no CFCommodityPrimaryIcon in plist");

    if 'UINewsstandIcon' in commodityIconFileDict:
        commodityIconName = commodityIconFileDict['UINewsstandIcon']

        iconapp = dirApp + commodityIconName
        if iconapp in zfile.namelist():
            zfile.extract(iconapp, path=path);

            commodityIconFile = os.path.join(path, commodityIconName);
            if os.path.exists(commodityIconFile):
                return commodityIconFile;
            else:
                commodityIconFile = None;
    else:
        h.logm("ERR",5,"no UINewsstandIcon in plist");

    if not commodityIconFile:
        h.logm("ERR",5,"commodityIconFile (IOS5)"+ commodityIconFile + " does not exist in BREAD");

    return None;
Esempio n. 48
0
def getIconFileIOS3(dirApp, zfile, path, plist):
    h.logm("DBG",5,"ACTION "+ h.getcalled());

    if not 'CFCommodityIconFile' in plist:
        return None;

    commodityIconName = plist['CFCommodityIconFile'];

    iconapp = dirApp + commodityIconName
    if iconapp in zfile.namelist():
        zfile.extract(iconapp, path=path);

        commodityIconFile = os.path.join(path, dirApp, commodityIconName);
        if os.path.exists(commodityIconFile):
            return commodityIconFile;
        
    h.logm("ERR",5,"commodityIconFile (IOS3)"+ commodityIconFile + " does not exist in BREAD");

    return None;
Esempio n. 49
0
def getIconFileIOS3(dirApp, zfile, path, plist):
    h.logm("DBG", 5, "ACTION " + h.getcalled())

    if not 'CFCommodityIconFile' in plist:
        return None

    commodityIconName = plist['CFCommodityIconFile']

    iconapp = dirApp + commodityIconName
    if iconapp in zfile.namelist():
        zfile.extract(iconapp, path=path)

        commodityIconFile = os.path.join(path, dirApp, commodityIconName)
        if os.path.exists(commodityIconFile):
            return commodityIconFile

    h.logm(
        "ERR", 5, "commodityIconFile (IOS3)" + commodityIconFile +
        " does not exist in BREAD")

    return None
Esempio n. 50
0
    def userPost(self):
        h.logm("DBG", 5, "ACTION " + h.getcalled())
        if request.method != 'POST':
            h.logm("ERR", 5, "EXCEPTION, method is " + request.method)
            return self.jsonErrorResponse(
                500, "adm/user action does only allow POST request method")

        h.logm("DBG", 5, "request.POST body: " + request.body)

        userSchema = json.loads(request.body)
        user = User(userSchema)

        db = self._py_object.app_globals.db
        if db.users.find_one({'name': user.name}):
            h.logm("INF", 5, "user already exist: " + str(user.encode()))
            return self.jsonErrorResponse(
                405,
                "user already exist with this name: " + str(user.encode()))

        db = self._py_object.app_globals.db
        if db.users.find_one({'email': user.email}):
            h.logm("INF", 5, "user already exist: " + str(user.encode()))
            return self.jsonErrorResponse(
                405,
                "user already exist with this email: " + str(user.encode()))

        h.logm("INF", 5, "trying to create user: "******"Cannot create user: "******"oid": str(userid)
        }

        return self.jsonResponse(responseDict)
Esempio n. 51
0
    def userDelete(self, id=None):
        h.logm("DBG", 5, "ACTION " + h.getcalled())
        if request.method != 'DELETE':
            h.logm("ERR", 5, "EXCEPTION, method is " + request.method)
            return self.jsonErrorResponse(
                500, "adm/user action does only allow DELETE request method")
        if not id:
            h.logm("ERR", 5, "EXCEPTION, parameter missing" + request.method)
            return self.jsonErrorResponse(407,
                                          "adm/user/id, missing parameter id")

        userid = str(id)
        h.logm("DBG", 5, "request w/ userid=" + userid)

        db = self._py_object.app_globals.db

        user = None

        try:
            user = db.users.find_one({'_id': ObjectId(userid)})
        except:
            return self.jsonErrorResponse(
                404, "Invalid Mongo DB User Id {'_id' : " + userid + '}')
        else:
            if not user:
                return self.jsonErrorResponse(404, "Invalid user id " + userid)

            h.logm("INF", 5, "found user: "******"$pull": {
            "users": (ObjectId(userid))
        }})
        db.users.remove({'_id': ObjectId(userid)})

        responseDict = {
            "oid": str(user['_id'])
        }

        return self.jsonResponse(responseDict)