async def common_role(self, ctx: Context, roleName=None): if (roleName): await ctx.send("Please specify a role!") return role = getRole(ctx, roleName) if (role == None): await ctx.send(f"No such role: `{roleName}`") return cur = conn.cursor() cur.execute("SELECT * FROM Roles WHERE RoleID == {role.id}'") if (len(cur.fetchall()) > 0): cur.execute(f""" DELETE FROM Roles WHERE RoleID == ? """, (role.id,)) await ctx.send(f"Removed {role} from the common roles") else: cur.execute(""" INSERT INTO Roles (RoleID, GuildID, Authority) VALUES (?, ?) """, (role.id, ctx.guild.id)) await ctx.send(f"Added {role} to the common roles") conn.commit()
def dropbox(self, auth=0, pincode=None, note=None): date = datetime.datetime.now().strftime('%I:%M%p on %B %d, %Y') (app_key, app_secret) = conn.execute('SELECT AppKey, AppSecret FROM Dropbox').fetchone() auth_flow = DropboxOAuth2FlowNoRedirect(app_key, app_secret) if not auth: return auth_flow.start() if pincode: try: access_token, user_id = auth_flow.finish(pincode) except ErrorResponse, e: print('Error: %s' % (e,)) return 'Unsuccessful.' print access_token if conn.execute('SELECT COUNT(*) FROM Dropbox WHERE AuthToken=?', (access_token,)).fetchone()[0]: rtn = 'Unsuccessful. Account already exists.' else: conn.execute('UPDATE Dropbox SET AuthToken=?, Note=?, DateAdded=? WHERE AppKey=?', (access_token, note, date, app_key)) conn.commit() rtn = 'Successful.' return rtn
def updateDB(self, location=None, locationDescription=None, background=None, twitterQuery=None, feed=None): if location: conn.execute('UPDATE HTMLSettings SET content=? WHERE idName=? ', ( location, 'location', )) if locationDescription: conn.execute('UPDATE HTMLSettings SET content=? WHERE idName=? ', ( locationDescription, 'locationDescription', )) if twitterQuery: conn.execute('UPDATE HTMLSettings SET content=? WHERE idName=? ', (twitterQuery, 'twitterQuery')) if feed: conn.execute('UPDATE HTMLSettings SET content=? WHERE idName=? ', ( feed, 'feed', )) conn.commit()
def dropbox(self, auth=0, pincode=None, note=None): date = datetime.datetime.now().strftime('%I:%M%p on %B %d, %Y') (app_key, app_secret ) = conn.execute('SELECT AppKey, AppSecret FROM Dropbox').fetchone() auth_flow = DropboxOAuth2FlowNoRedirect(app_key, app_secret) if not auth: return auth_flow.start() if pincode: try: access_token, user_id = auth_flow.finish(pincode) except ErrorResponse, e: print('Error: %s' % (e, )) return 'Unsuccessful.' print access_token if conn.execute('SELECT COUNT(*) FROM Dropbox WHERE AuthToken=?', (access_token, )).fetchone()[0]: rtn = 'Unsuccessful. Account already exists.' else: conn.execute( 'UPDATE Dropbox SET AuthToken=?, Note=?, DateAdded=? WHERE AppKey=?', (access_token, note, date, app_key)) conn.commit() rtn = 'Successful.' return rtn
def delete_link(self, link): find_id = conn.execute('SELECT * FROM YouTube WHERE VideoId = (?);', (link,)).fetchone() find_name = conn.execute('SELECT VideoName FROM YouTube WHERE VideoId = (?);', (link,)).fetchone() delete_video(find_name[0]) conn.execute('DELETE FROM YouTube WHERE VideoId = (?);', (find_id[0],)) conn.commit()
def copy_dropbox_folder(): if client: copy_folder('/') for f in conn.execute('SELECT * FROM Files').fetchall(): if f[0] not in updated_files: conn.execute('DELETE FROM Files WHERE FilePath=?', (f[0],)) conn.commit() os.remove(os.path.join(ROOT_DIR, 'static/public/data/dropbox_files', f[0][1:])) print 'WARNING: The file with the path: ' + f[0] + ' was removed.'
def dropbox_db(files): try: for f in json.loads(files): conn.execute('UPDATE Files SET ToDisplay=?, FileOrder=? WHERE FilePath=?', (f['todisplay'], f['order'], f['filepath'],)) conn.commit() return 'Successful.' except sql.Error: return 'Unsuccessful.'
def tweets(self, tweetlist): try: for tweet in json.loads(tweetlist): conn.execute('UPDATE Tweets SET ToDisplay=?, TweetOrder=? WHERE TweetId=?', (tweet['todisplay'], tweet['order'], tweet['tweetid'],)) conn.commit() return 'Successful.' except sql.Error: return 'Unsuccessful.'
def save_file(path, f, file_type, message): out = open(os.path.join(ROOT_DIR, 'static/public/data/dropbox_files', path[1:]), 'w') out.write(f.read()) out.close() conn.execute('INSERT OR IGNORE INTO Files(FilePath, ToDisplay, FileOrder, Type) VALUES (?, ?, ?, ?)', (os.path.join(ROOT_DIR, 'static/public/data/dropbox_files', path), 1, -1, file_type,)) conn.commit() updated_files.append(path) print 'SUCCESS: ' + path + ' was ' + message + '.'
def services(self, servicelist): try: for service in json.loads(servicelist): conn.execute('UPDATE FrontEndOrder SET ToDisplay=?, ServicesOrder=? WHERE Service=?', (service['todisplay'], service['order'], service['name'],)) conn.commit() return 'Successful.' except sql.Error: return 'Unsuccessful.'
def deti_news(): try: feed_source = conn.execute('SELECT * FROM HTMLSettings WHERE IdName=?', ('feed',)).fetchone()[1] feed_content = feedparser.parse(feed_source) news = {"title": feed_content.feed.title, "news": []} # delete all the images files = glob.glob(os.path.join(ROOT_DIR, 'static/public/data/feed_imgs/') + '*') for f in files: os.remove(f) conn.execute("DELETE FROM News;") for entry in feed_content.entries: news['news'] += [{'author': parse_author(entry.author) if hasattr(entry, 'author') else '', 'summary': entry.summary if hasattr(entry, 'summary') else '', 'title': entry.title if hasattr(entry, 'title') else '', 'date': parse_date(str(entry.updated)) if hasattr(entry, 'entry.updated') else ''}] for i in range(len(news['news'])): tmp = news["news"][i]['summary'] new_tmp = download_photo(tmp) # try to clean... new_tmp = new_tmp.replace('<p class="MsoNormal"></p>', '') new_tmp = new_tmp.replace('<p></p>', '') new_tmp = new_tmp.replace('<br>', '') new_tmp = new_tmp.replace('<br />', '') new_tmp = new_tmp.replace('<p> </p>', '') # news without images tmp = tmp.replace('<p class="MsoNormal"></p>', '') tmp = tmp.replace('<p></p>', '') tmp = tmp.replace('<br>', '') tmp = tmp.replace('<br />', '') tmp = tmp.replace('<p> </p>', '') spaces = re.findall('(<p[^>]*><p[^>]*>.</p></p> )', new_tmp) for space in spaces: new_tmp = new_tmp.replace(space, "") tmp = tmp.replace(space, "") if new_tmp: conn.execute('INSERT INTO News (Title, Date_Updated, Author, Content) VALUES (?,?,?,?);', (news['news'][i]['title'], news['news'][i]['date'], news['news'][i]['author'], new_tmp)) conn.commit() else: conn.execute('INSERT INTO News (Title, Date_Updated, Author, Content) VALUES (?,?,?,?);', (news['news'][i]['title'], news['news'][i]['date'], news['news'][i]['author'], tmp)) conn.commit() except Exception, e: print e.message
def updateDB(self, location=None, locationDescription=None, background=None, twitterQuery=None, feed=None): if location: conn.execute('UPDATE HTMLSettings SET content=? WHERE idName=? ', (location, 'location',)) if locationDescription: conn.execute('UPDATE HTMLSettings SET content=? WHERE idName=? ', (locationDescription, 'locationDescription',)) if twitterQuery: conn.execute('UPDATE HTMLSettings SET content=? WHERE idName=? ', (twitterQuery, 'twitterQuery')) if feed: conn.execute('UPDATE HTMLSettings SET content=? WHERE idName=? ', (feed, 'feed',)) conn.commit()
def delete_link(self, link): find_id = conn.execute('SELECT * FROM YouTube WHERE VideoId = (?);', (link, )).fetchone() find_name = conn.execute( 'SELECT VideoName FROM YouTube WHERE VideoId = (?);', (link, )).fetchone() delete_video(find_name[0]) conn.execute('DELETE FROM YouTube WHERE VideoId = (?);', (find_id[0], )) conn.commit()
def copy_dropbox_folder(): if client: copy_folder('/') for f in conn.execute('SELECT * FROM Files').fetchall(): if f[0] not in updated_files: conn.execute('DELETE FROM Files WHERE FilePath=?', (f[0], )) conn.commit() os.remove( os.path.join(ROOT_DIR, 'static/public/data/dropbox_files', f[0][1:])) print 'WARNING: The file with the path: ' + f[ 0] + ' was removed.'
def populate_db(count=100): query = conn.execute('SELECT Content FROM HTMLSettings WHERE idName=?', ('twitterQuery',)).fetchone()[0] try: tweets = api.GetSearch(term=query, count=count) conn.execute('DELETE FROM Tweets WHERE TweetOrder > (SELECT TweetOrder FROM ' '(SELECT TweetOrder FROM Tweets ORDER BY TweetOrder ASC LIMIT 1 OFFSET 127))') for tweet in tweets: conn.execute('INSERT OR REPLACE INTO Tweets (TweetId, Author, Tweet, ToDisplay) VALUES ' '(?, ?, ?, COALESCE((SELECT ToDisplay FROM Tweets WHERE TweetId=?), 1))', (tweet.id, tweet.user.name, tweet.text, tweet.id)) conn.commit() except twitter.TwitterError, e: print e
def tweets(self, tweetlist): try: for tweet in json.loads(tweetlist): conn.execute( 'UPDATE Tweets SET ToDisplay=?, TweetOrder=? WHERE TweetId=?', ( tweet['todisplay'], tweet['order'], tweet['tweetid'], )) conn.commit() return 'Successful.' except sql.Error: return 'Unsuccessful.'
def dropbox_db(files): try: for f in json.loads(files): conn.execute( 'UPDATE Files SET ToDisplay=?, FileOrder=? WHERE FilePath=?', ( f['todisplay'], f['order'], f['filepath'], )) conn.commit() return 'Successful.' except sql.Error: return 'Unsuccessful.'
def services(self, servicelist): try: for service in json.loads(servicelist): conn.execute( 'UPDATE FrontEndOrder SET ToDisplay=?, ServicesOrder=? WHERE Service=?', ( service['todisplay'], service['order'], service['name'], )) conn.commit() return 'Successful.' except sql.Error: return 'Unsuccessful.'
async def add_character(self, ctx, argc): if (len(argc) < 2): await ctx.send("Usage: character add [Character Name]") return name = " ".join(argc) cur = conn.cursor() cur.execute(""" INSERT INTO Character (PlayerID, Name) VALUES (?, ?) """, (ctx.message.author.id, name,)) await ctx.send(f"Added {name} to {ctx.message.author}'s characters!") conn.commit()
def save_file(path, f, file_type, message): out = open( os.path.join(ROOT_DIR, 'static/public/data/dropbox_files', path[1:]), 'w') out.write(f.read()) out.close() conn.execute( 'INSERT OR IGNORE INTO Files(FilePath, ToDisplay, FileOrder, Type) VALUES (?, ?, ?, ?)', ( os.path.join(ROOT_DIR, 'static/public/data/dropbox_files', path), 1, -1, file_type, )) conn.commit() updated_files.append(path) print 'SUCCESS: ' + path + ' was ' + message + '.'
async def del_character(self, ctx, argc): if (len(argc) < 2): await ctx.send("Usage: character remove [Character Name]") return name = " ".join(argc) cur = conn.cursor() cur.execute(""" DELETE FROM Character WHERE PlayerID == ? AND Name == ? """, (ctx.message.author.id, name,)) if (cur.fetchone() != None): await ctx.send(f"{name} has been deleted!") else: await ctx.send(f"You don't have a character named {name}!") conn.commit()
def user(self, current_password=None, new_password=None, first_name=None, last_name=None, email=None): if not ((current_password and new_password) or first_name or last_name or email): raise cherrypy.HTTPRedirect('/admin/pages/profile.html#error=No parameters received') username = cherrypy.session[SESSION_USER]['UserId'] date = datetime.datetime.now().strftime('%B %d, %Y') if current_password and new_password: if current_password == conn.execute('SELECT Password FROM Users WHERE UserId=?', (username,)).fetchone()[0]: conn.execute('UPDATE Users SET Password=?, Date=? WHERE UserId=?', (new_password, date, username)) else: raise cherrypy.HTTPRedirect('/admin/pages/profile.html#error=Wrong password') if first_name: conn.execute('UPDATE Users SET FirstName=?, Date=? WHERE UserId=?', (first_name, date, username)) cherrypy.session[SESSION_USER]['FirstName'] = first_name if last_name: conn.execute('UPDATE Users SET LastName=?, Date=? WHERE UserId=?', (last_name, date, username)) cherrypy.session[SESSION_USER]['LastName'] = last_name if email: conn.execute('UPDATE Users SET Email=?, Date=? WHERE UserId=?', (email, date, username)) cherrypy.session[SESSION_USER]['Email'] = email conn.commit() raise cherrypy.HTTPRedirect('/admin/pages/profile.html')
def user(self, current_password=None, new_password=None, first_name=None, last_name=None, email=None): if not ((current_password and new_password) or first_name or last_name or email): raise cherrypy.HTTPRedirect( '/admin/pages/profile.html#error=No parameters received') username = cherrypy.session[SESSION_USER]['UserId'] date = datetime.datetime.now().strftime('%B %d, %Y') if current_password and new_password: if current_password == conn.execute( 'SELECT Password FROM Users WHERE UserId=?', (username, )).fetchone()[0]: conn.execute( 'UPDATE Users SET Password=?, Date=? WHERE UserId=?', (new_password, date, username)) else: raise cherrypy.HTTPRedirect( '/admin/pages/profile.html#error=Wrong password') if first_name: conn.execute('UPDATE Users SET FirstName=?, Date=? WHERE UserId=?', (first_name, date, username)) cherrypy.session[SESSION_USER]['FirstName'] = first_name if last_name: conn.execute('UPDATE Users SET LastName=?, Date=? WHERE UserId=?', (last_name, date, username)) cherrypy.session[SESSION_USER]['LastName'] = last_name if email: conn.execute('UPDATE Users SET Email=?, Date=? WHERE UserId=?', (email, date, username)) cherrypy.session[SESSION_USER]['Email'] = email conn.commit() raise cherrypy.HTTPRedirect('/admin/pages/profile.html')
def download(link): yt = pytube.YouTube() # Set the video URL. yt.from_url(link) # Once set, you can see all the codec and quality options YouTube has made # available for the particular video by printing videos. # pprint(yt.get_videos()) # [<Video: MPEG-4 Visual (.3gp) - 144p>, # <Video: MPEG-4 Visual (.3gp) - 240p>, # <Video: Sorenson H.263 (.flv) - 240p>, # <Video: H.264 (.flv) - 360p>, # <Video: H.264 (.flv) - 480p>, # <Video: H.264 (.mp4) - 360p>, # <Video: H.264 (.mp4) - 720p>, # <Video: VP8 (.webm) - 360p>, # <Video: VP8 (.webm) - 480p>] # The filename is automatically generated based on the video title. # You can override this by manually setting the filename. # view the auto generated filename: # print(yt.filename) # Pulp Fiction - Dancing Scene [HD] # set the filename: # yt.set_filename('example') # You can also filter the criteria by filetype. # pprint(yt.filter('flv')) # [<Video: Sorenson H.263 (.flv) - 240p>, # <Video: H.264 (.flv) - 360p>, # <Video: H.264 (.flv) - 480p>] # notice that the list is ordered by lowest resolution to highest. If you # wanted the highest resolution available for a specific file type, you # can simply do: # print(yt.filter('mp4')[-1]) # <Video: H.264 (.mp4) - 720p> # you can also get all videos for a given resolution videos = yt.filter(extension='mp4') or yt.filter(extension='webm') if not len(videos): return json.dumps({'status': 400}) video = None for v in videos: if v.resolution >= '360p': video = v break if video is None: video = videos[-1] # [<Video: H.264 (.flv) - 480p>, # <Video: VP8 (.webm) - 480p>] # to select a video by a specific resolution and filetype you can use the get # method. # NOTE: get() can only be used if and only if one object matches your criteria. # for example: # pprint(yt.videos) # [<Video: MPEG-4 Visual (.3gp) - 144p>, # <Video: MPEG-4 Visual (.3gp) - 240p>, # <Video: Sorenson H.263 (.flv) - 240p>, # <Video: H.264 (.flv) - 360p>, # <Video: H.264 (.flv) - 480p>, # <Video: H.264 (.mp4) - 360p>, # <Video: H.264 (.mp4) - 720p>, # <Video: VP8 (.webm) - 360p>, # <Video: VP8 (.webm) - 480p>] # Notice we have two H.264 (.mp4) available to us.. now if we try to call get() # on mp4.. # video = yt.get('mp4') # MultipleObjectsReturned: get() returned more than one object -- it returned 2! # In this case, we'll need to specify both the codec (mp4) and resolution # (either 360p or 720p). # Okay, let's download it! # try: video.download(os.path.join(ROOT_DIR, 'static/public/data/videos/')) # except Exception: # return json.dumps({'status': 400}) # Downloading: Pulp Fiction - Dancing Scene.mp4 Bytes: 37561829 # 37561829 [100.00%] # Note: If you wanted to choose the output directory, simply pass it as an # argument to the download method. # video.download('/tmp/') conn.execute('INSERT INTO YouTube VALUES (?,?,?);', (link, os.path.join(ROOT_DIR, 'static/public/data/videos/' + yt.filename + '.mp4'), yt.filename)) conn.commit()
return oauth_client.authorization_url(self.AUTHORIZATION_URL) # Generating and signing request for an access token oauth_client = OAuth1Session( consumer_key, client_secret=consumer_secret, resource_owner_key=self.resp.get('oauth_token'), resource_owner_secret=self.resp.get('oauth_token_secret'), verifier=pincode) try: resp = oauth_client.fetch_access_token(self.ACCESS_TOKEN_URL) conn.execute( 'UPDATE Twitter SET AccessKey=?, AccessSecret=?, Note=?, DateAdded=? WHERE ConsumerKey=?', (resp.get('oauth_token'), resp.get('oauth_token_secret'), note, date, consumer_key)) conn.commit() except ValueError, e: raise cherrypy.HTTPRedirect( '/admin/pages/accounts.html#error=Invalid respond from Twitter requesting access token: %s' % e) return 'Successful' class Get: def __init__(self): pass @cherrypy.expose def dropbox(self): cherrypy.response.headers['Content-Type'] = "application/json"
def deti_news(): try: feed_source = conn.execute('SELECT * FROM HTMLSettings WHERE IdName=?', ('feed', )).fetchone()[1] feed_content = feedparser.parse(feed_source) news = {"title": feed_content.feed.title, "news": []} # delete all the images files = glob.glob( os.path.join(ROOT_DIR, 'static/public/data/feed_imgs/') + '*') for f in files: os.remove(f) conn.execute("DELETE FROM News;") for entry in feed_content.entries: news['news'] += [{ 'author': parse_author(entry.author) if hasattr(entry, 'author') else '', 'summary': entry.summary if hasattr(entry, 'summary') else '', 'title': entry.title if hasattr(entry, 'title') else '', 'date': parse_date(str(entry.updated)) if hasattr( entry, 'entry.updated') else '' }] for i in range(len(news['news'])): tmp = news["news"][i]['summary'] new_tmp = download_photo(tmp) # try to clean... new_tmp = new_tmp.replace('<p class="MsoNormal"></p>', '') new_tmp = new_tmp.replace('<p></p>', '') new_tmp = new_tmp.replace('<br>', '') new_tmp = new_tmp.replace('<br />', '') new_tmp = new_tmp.replace('<p> </p>', '') # news without images tmp = tmp.replace('<p class="MsoNormal"></p>', '') tmp = tmp.replace('<p></p>', '') tmp = tmp.replace('<br>', '') tmp = tmp.replace('<br />', '') tmp = tmp.replace('<p> </p>', '') spaces = re.findall('(<p[^>]*><p[^>]*>.</p></p> )', new_tmp) for space in spaces: new_tmp = new_tmp.replace(space, "") tmp = tmp.replace(space, "") if new_tmp: conn.execute( 'INSERT INTO News (Title, Date_Updated, Author, Content) VALUES (?,?,?,?);', (news['news'][i]['title'], news['news'][i]['date'], news['news'][i]['author'], new_tmp)) conn.commit() else: conn.execute( 'INSERT INTO News (Title, Date_Updated, Author, Content) VALUES (?,?,?,?);', (news['news'][i]['title'], news['news'][i]['date'], news['news'][i]['author'], tmp)) conn.commit() except Exception, e: print e.message
def download(link): yt = pytube.YouTube() # Set the video URL. yt.from_url(link) # Once set, you can see all the codec and quality options YouTube has made # available for the particular video by printing videos. # pprint(yt.get_videos()) # [<Video: MPEG-4 Visual (.3gp) - 144p>, # <Video: MPEG-4 Visual (.3gp) - 240p>, # <Video: Sorenson H.263 (.flv) - 240p>, # <Video: H.264 (.flv) - 360p>, # <Video: H.264 (.flv) - 480p>, # <Video: H.264 (.mp4) - 360p>, # <Video: H.264 (.mp4) - 720p>, # <Video: VP8 (.webm) - 360p>, # <Video: VP8 (.webm) - 480p>] # The filename is automatically generated based on the video title. # You can override this by manually setting the filename. # view the auto generated filename: # print(yt.filename) # Pulp Fiction - Dancing Scene [HD] # set the filename: # yt.set_filename('example') # You can also filter the criteria by filetype. # pprint(yt.filter('flv')) # [<Video: Sorenson H.263 (.flv) - 240p>, # <Video: H.264 (.flv) - 360p>, # <Video: H.264 (.flv) - 480p>] # notice that the list is ordered by lowest resolution to highest. If you # wanted the highest resolution available for a specific file type, you # can simply do: # print(yt.filter('mp4')[-1]) # <Video: H.264 (.mp4) - 720p> # you can also get all videos for a given resolution videos = yt.filter(extension='mp4') or yt.filter(extension='webm') if not len(videos): return json.dumps({'status': 400}) video = None for v in videos: if v.resolution >= '360p': video = v break if video is None: video = videos[-1] # [<Video: H.264 (.flv) - 480p>, # <Video: VP8 (.webm) - 480p>] # to select a video by a specific resolution and filetype you can use the get # method. # NOTE: get() can only be used if and only if one object matches your criteria. # for example: # pprint(yt.videos) # [<Video: MPEG-4 Visual (.3gp) - 144p>, # <Video: MPEG-4 Visual (.3gp) - 240p>, # <Video: Sorenson H.263 (.flv) - 240p>, # <Video: H.264 (.flv) - 360p>, # <Video: H.264 (.flv) - 480p>, # <Video: H.264 (.mp4) - 360p>, # <Video: H.264 (.mp4) - 720p>, # <Video: VP8 (.webm) - 360p>, # <Video: VP8 (.webm) - 480p>] # Notice we have two H.264 (.mp4) available to us.. now if we try to call get() # on mp4.. # video = yt.get('mp4') # MultipleObjectsReturned: get() returned more than one object -- it returned 2! # In this case, we'll need to specify both the codec (mp4) and resolution # (either 360p or 720p). # Okay, let's download it! # try: video.download(os.path.join(ROOT_DIR, 'static/public/data/videos/')) # except Exception: # return json.dumps({'status': 400}) # Downloading: Pulp Fiction - Dancing Scene.mp4 Bytes: 37561829 # 37561829 [100.00%] # Note: If you wanted to choose the output directory, simply pass it as an # argument to the download method. # video.download('/tmp/') conn.execute( 'INSERT INTO YouTube VALUES (?,?,?);', (link, os.path.join(ROOT_DIR, 'static/public/data/videos/' + yt.filename + '.mp4'), yt.filename)) conn.commit()
'/admin/pages/accounts.html#error=Invalid response from Twitter requesting temp token: %s' % e) if not pincode: # Else pin code is already known # URL to the pin code page (used to obtain an Authentication Token) return oauth_client.authorization_url(self.AUTHORIZATION_URL) # Generating and signing request for an access token oauth_client = OAuth1Session(consumer_key, client_secret=consumer_secret, resource_owner_key=self.resp.get('oauth_token'), resource_owner_secret=self.resp.get('oauth_token_secret'), verifier=pincode) try: resp = oauth_client.fetch_access_token(self.ACCESS_TOKEN_URL) conn.execute('UPDATE Twitter SET AccessKey=?, AccessSecret=?, Note=?, DateAdded=? WHERE ConsumerKey=?', (resp.get('oauth_token'), resp.get('oauth_token_secret'), note, date, consumer_key)) conn.commit() except ValueError, e: raise cherrypy.HTTPRedirect( '/admin/pages/accounts.html#error=Invalid respond from Twitter requesting access token: %s' % e) return 'Successful' class Get: def __init__(self): pass @cherrypy.expose def dropbox(self): cherrypy.response.headers['Content-Type'] = "application/json" dropbox = conn.execute('SELECT AuthToken, Note, DateAdded FROM Dropbox').fetchone()