Ejemplo n.º 1
0
    def del_follow(self, selfname, friendname):
         if (not self.check_user_exist_by_name(selfname))  \
             or (not self.check_user_exist_by_name(friendname)):
             return errorno.server_error(errorno.USER_NOT_EXISTED[0], \
                                         errorno.USER_NOT_EXISTED[1]).dumps()

         selfid   = self.user._get_user_id(selfname)
         friendid = self.user._get_user_id(friendname)
         self._del_follow(selfid, friendid)
Ejemplo n.º 2
0
 def POST(self):
     try:
         model = mmodel()
         data = json.loads(web.data())
         if (model.check_user_exist_by_name(data['friend_name'])):
             #TODO:
             model.add_friend(data['username'],data['friend_name'])
         else:
             return errorno.server_error(errorno.VIDEO_NOT_EXISTED[0], errorno.VIDEO_NOT_EXISTED[1]).dumps()
     except Exception as e:
         print traceback.print_exc()
         return e
     return " user_add %s " % model.get_user_base_info(data['username'])
Ejemplo n.º 3
0
    def POST(self):
        try:
            model = mmodel()
            sha1 = hashlib.sha1()
            upfile    = web.input(uploaded_file={}, thumb_nail={})
            owner     = upfile.get('video_owner')
            place     = upfile.get('video_place')
            title     = upfile.get('video_title')
            authority = upfile.get('video_is_public')

            print owner,place,title,authority 
            urldir = '/video/'
            filedir = '/var/www' + urldir
#            print owner, sha1.hexdigest(), authority, title
            if not os.path.exists(filedir):
                os.mkdir(filedir)

            sha1.update(upfile.uploaded_file.value)      
            
            filepath = ''.join([filedir, sha1.hexdigest(), '.mp4'])
            with open(filepath, 'wb') as saved:
                saved.write(upfile.uploaded_file.file.read())

            filepath_thumb = ''.join([filedir, sha1.hexdigest(), '.png'])
            with open(filepath_thumb, 'wb') as thumb_file:
                thumb_file.write(upfile.thumb_nail.file.read())
                
            video_url = ''.join([urldir, sha1.hexdigest(), '.mp4'])
            thumb_url = ''.join([urldir, sha1.hexdigest(), '.png'])
            
            ret = model.new_video(owner, filepath, sha1.hexdigest(), title, place,url=video_url, thumb_url=thumb_url)
            if (ret == -1):
                return errorno.server_error(errorno.VIDEO_ALREADY_EXISTED[0], errorno.VIDEO_ALREADY_EXISTED[1])
            elif (ret == -2):
                return 'user not existed'

        except Exception as e:
            print traceback.print_exc()