def initiate(): """ Generate a new brand new table (database) Generally for starting the new game. Args: none Returns: none Raises: IOError : """ def check_database_file(): """ """ # Check for old database file if not os.path.exists(configuration.CONFIG['database_path']): service.error("There is no game.sqlite in {}".format( configuration.CONFIG['database_path'])) database.reset() database.connect() check_database_file() database.create(configuration.CONFIG['database_create_file'])
def test_message_edit(): database.reset() #send a message result = get_user("user1") u_id = result['u_id'] token = result['token'] temp = channels.channels_create(token, "channel1", True) channel_id = temp['channel_id'] msg = message.message_send(token, channel_id, "hello") message_id = msg['message_id'] #edit the message return_val = message.message_edit(token, message_id, "hi") assert return_val == {} #edit the message to an empty string so the message is deleted message.message_edit(token, message_id, "") #try to delete the message which is deleted with pytest.raises(InputError) as e: message.message_remove(token, message_id) #have a new user join the channel and send a message result = get_user("user2") u_id2 = result['u_id'] token2 = result['token'] channel.channel_join(token2, channel_id) msg2 = message.message_send(token2, channel_id, "hello") #admin edit the new message temp2 = message.message_edit(token, msg2['message_id'], "hi") assert temp2 == {} #new user edit him message temp3 = message.message_edit(token2, msg2['message_id'], "hillo") assert temp3 == {}
def setup_all(): def _join_to_data_dir(filename): # this file is twerpy/lib/setup.py, so navigate to twerpy/ # the join with data/ to get twerpy/data/ return os.path.join( os.path.dirname(os.path.dirname( os.path.abspath(__file__))), "data", filename) access_token_key = raw_input("Enter access token key: ") access_token_secret = raw_input("Enter access token secret: ") consumer_key = raw_input("Enter consumer key: ") consumer_secret = raw_input("Enter consumer secret: ") default_db_filename = raw_input("Enter default database file name\n" + "Leave blank to use 'tweets.db'") if len(default_db_filename) == 0: default_db_filename = "tweets.db" with open(_join_to_data_dir("user_settings.py"), "w") as settings_file: settings_file.write("access_token_key = \"{0}\"\n".format(access_token_key)) settings_file.write("access_token_secret = \"{0}\"\n".format(access_token_secret)) settings_file.write("consumer_key = \"{0}\"\n".format(consumer_key)) settings_file.write("consumer_secret = \"{0}\"\n".format(consumer_secret)) settings_file.write("default_db_filename = \"{0}\"\n".format(default_db_filename)) db.reset(_join_to_data_dir(default_db_filename))
def test_message_remove(): #create a message database.reset() result = get_user("user1") u_id = result['u_id'] token = result['token'] channel_result = channels.channels_create(token, "channel1", True) msgid1 = message.message_send(token, channel_result['channel_id'], "hello") msg1 = msgid1['message_id'] #remove the message message.message_remove(token, msg1) #have a new user and join the channel result = get_user("user2") u_id1 = result['u_id'] token1 = result['token'] channel.channel_join(token1, channel_result['channel_id']) #new user send a message msgid2 = message.message_send(token1, channel_result['channel_id'], "hello") msg2 = msgid2['message_id'] #admin remove the new message message.message_remove(token, msg2) #new user send another message msgid3 = message.message_send(token1, channel_result['channel_id'], "wow") #new user remove the message message.message_remove(token1, msgid3['message_id'])
def run_tests(): database.reset() database.cache() results = main() pdb.set_trace() if results.wasSuccessful(): sys.exit(0) sys.exit(1)
def test_post(self): database.reset() self.assertEquals({}, database.data) self.app.post('/data', data=json.dumps([self.player1])) self.assertEquals({'Nick|100': self.player1}, database.data) self.app.post('/data', data=json.dumps([self.player2])) self.assertEquals({ 'Nick|100': self.player1, 'Ken|200': self.player2 }, database.data)
def test_message_send(): database.reset() #get a user result = get_user("user1") u_id = result['u_id'] token = result['token'] #get a channel channel = channels.channels_create(token, "channel1", True) #send the message msgid = message.message_send(token, channel['channel_id'], "hello")
def process(self, collection_dir, docstruc_filename, filename_extension, start_from_scratch): """ This function relies on several methods to: 1. Set up the database if necessary 2. Extract metadata, populate the narratives, sentences, and paragraphs tables 3. Process the sentences by tokenizing and indexing the words 4. Process the sentences by performing grammatical parsing :param str collection_dir: The directory whose files should be processed. :param str docstructure_file_name: The name of the JSON file that describes the structure in the document files. :param str file_name_extension: Files with this extension will be parsed as documents. :param boolean start_from_scratch: If true, then the tables in the database will be recreated. """ Base.commit_on_save = False # Set up database if necessary if start_from_scratch is True: database.reset() # Extract metadata, populate documents, sentences, and doc structure # tables if not "true" in logger.get(self.project, "finished_recording_text_and_metadata"): self.project_logger.info("Extracting document text and metadata") self.extract_record_metadata(collection_dir, docstruc_filename, filename_extension) # Parse the documents if ((app.config["GRAMMATICAL_PROCESSING"] or (app.config["WORD_TO_WORD_SIMILARITY"] and app.config["PART_OF_SPEECH_TAGGING"])) and not "true" in logger.get(self.project, "finished_grammatical_processing").lower()): self.project_logger.info("Parsing documents") self.parse_documents() # Calculate word TFIDFs if not "true" in logger.get(self.project, "tfidf_done").lower(): self.project_logger.info("Calculating TF IDF's") # TODO: implement tfidf method in document # Calculate word-to-word-similarities if (app.config["WORD_TO_WORD_SIMILARITY"] and not "true" in logger.get(self.project, "word_similarity_calculations_done")): self.project_logger.info("Calculating Lin Similarities")
def test_message_send_except(): database.reset() #long message result = get_user("user1") u_id = result['u_id'] token = result['token'] channel = channels.channels_create(token, "channel1", True) with pytest.raises(InputError) as e: message.message_send(token, channel['channel_id'], 'a'*1001) #try to send a message with a user not in the channel result = get_user("user2") u_id = result['u_id'] token = result['token'] with pytest.raises(AccessError) as e: message.message_send(token, channel['channel_id'], "hello")
def check_version(self): ''' Check the database version to ensure we do not need to do a reset. ''' with Database('emby') as embydb: version = emby_db.EmbyDatabase(embydb.cursor).get_version() LOG.info("---[ db/%s ]", version) if version and compare_version(version, "3.1.0") < 0: resp = dialog("yesno", heading=_('addon_name'), line1=_(33022)) if not resp: LOG.warn("Database version is out of date! USER IGNORED!") dialog("ok", heading=_('addon_name'), line1=_(33023)) raise Exception("User backed out of a required database reset") else: reset() raise Exception("Completed database reset")
def test_message_edit_except(): #send a message database.reset() result = get_user("user1") u_id = result['u_id'] token = result['token'] temp = channels.channels_create(token, "channel1", True) channel_id = temp['channel_id'] temp1 = message.message_send(token, channel_id, "hello") msg_id = temp1['message_id'] #create a new user and join the channel result = get_user("user2") u_id2 = result['u_id'] token2 = result['token'] channel.channel_join(token2, channel_id) # try to use new user's token to edit the message with pytest.raises(AccessError) as e: message.message_edit(token2, msg_id, "hi") # try to edit the message to more than 1000 characters with pytest.raises(InputError) as e: message.message_edit(token, msg_id, 'h'*1001)
def test_message_remove_except(): database.reset() #create a message and remove it result = get_user("user1") u_id = result['u_id'] token = result['token'] temp = channels.channels_create(token, "channel1", True) channel_id = temp['channel_id'] msg = message.message_send(token, channel_id, "hello") message.message_remove(token, msg['message_id']) #try to remove it again with pytest.raises(InputError) as e: message.message_remove(token, msg['message_id']) #create the same message again msg = message.message_send(token, channel_id, "hello") #create a new user and join the channel and use the new user's token to remove the message result = get_user("user2") u_id = result['u_id'] token = result['token'] channel.channel_join(token, channel_id) with pytest.raises(AccessError) as e: message.message_remove(token, msg['message_id'])
def __init__(self): ''' Parse the parameters. Reroute to our service.py where user is fully identified already. ''' base_url = ADDON_BASE_URL path = QUERY_STRING try: params = dict(parse_qsl(path[1:])) except Exception: params = {} mode = params.get('mode') server = params.get('server') if server == 'None': server = None jellyfin_client = Jellyfin(server).get_client() api_client = jellyfin_client.jellyfin addon_data = xbmc.translatePath( "special://profile/addon_data/plugin.video.jellyfin/data.json") try: with open(addon_data, 'rb') as infile: data = json.load(infile) server_data = data['Servers'][0] api_client.config.data['auth.server'] = server_data.get('address') api_client.config.data['auth.server-name'] = server_data.get( 'Name') api_client.config.data['auth.user_id'] = server_data.get('UserId') api_client.config.data['auth.token'] = server_data.get( 'AccessToken') except Exception as e: LOG.warning('Addon appears to not be configured yet: {}'.format(e)) LOG.info("path: %s params: %s", path, JsonDebugPrinter(params)) if '/extrafanart' in base_url: jellyfin_path = path[1:] jellyfin_id = params.get('id') get_fanart(jellyfin_id, jellyfin_path, server, api_client) elif '/Extras' in base_url or '/VideoFiles' in base_url: jellyfin_path = path[1:] jellyfin_id = params.get('id') get_video_extras(jellyfin_id, jellyfin_path, server, api_client) elif mode == 'play': item = api_client.get_item(params['id']) item["resumePlayback"] = sys.argv[3].split(":")[1] == "true" Actions(server, api_client).play(item, params.get('dbid'), params.get('transcode') == 'true', playlist=params.get('playlist') == 'true') elif mode == 'playlist': api_client.post_session( api_client.config.data['app.session'], "Playing", { 'PlayCommand': "PlayNow", 'ItemIds': params['id'], 'StartPositionTicks': 0 }) elif mode == 'deviceid': client.reset_device_id() elif mode == 'reset': reset() elif mode == 'delete': delete_item() elif mode == 'refreshboxsets': event('SyncLibrary', {'Id': "Boxsets:Refresh"}) elif mode == 'nextepisodes': get_next_episodes(params['id'], params['limit']) elif mode == 'browse': browse(params.get('type'), params.get('id'), params.get('folder'), server, api_client) elif mode == 'synclib': event('SyncLibrary', {'Id': params.get('id')}) elif mode == 'updatelib': event('SyncLibrary', {'Id': params.get('id'), 'Update': True}) elif mode == 'repairlib': event('RepairLibrary', {'Id': params.get('id')}) elif mode == 'removelib': event('RemoveLibrary', {'Id': params.get('id')}) elif mode == 'repairlibs': event('RepairLibrarySelection') elif mode == 'updatelibs': event('SyncLibrarySelection') elif mode == 'removelibs': event('RemoveLibrarySelection') elif mode == 'addlibs': event('AddLibrarySelection') elif mode == 'addserver': event('AddServer') elif mode == 'login': event('ServerConnect', {'Id': server}) elif mode == 'removeserver': event('RemoveServer', {'Id': server}) elif mode == 'settings': xbmc.executebuiltin('Addon.OpenSettings(plugin.video.jellyfin)') elif mode == 'adduser': add_user(api_client) elif mode == 'updatepassword': event('UpdatePassword') elif mode == 'thememedia': get_themes(api_client) elif mode == 'managelibs': manage_libraries() elif mode == 'backup': backup() elif mode == 'restartservice': window('jellyfin.restart.bool', True) else: listing()
def setup_db(db_filename): logging.info("Creating new database file {0} in data directory".format(db_filename)) db.reset(db_filename)
from app.models import * from database import reset import pdb reset() p=Project(name="test") w=Word(word="foo") w2=Word(word="bar") w3=Word(word="mar") s=Sentence(text="foo bar") Project.active_project = p s.add_word(w) print(w.sentences) p2=Project(name="test2") s2=Sentence(text="foo mar") Project.active_project = p2 s2.add_word(w) print(w.sentences) print("\n==============\n") se=Sequence(sequence="foo bar")
def __init__(self): ''' Parse the parameters. Reroute to our service.py where user is fully identified already. ''' base_url = sys.argv[0] path = sys.argv[2] try: params = dict(urlparse.parse_qsl(path[1:])) except Exception: params = {} mode = params.get('mode') server = params.get('server') if server == 'None': server = None LOG.warn("path: %s params: %s", path, json.dumps(params, indent=4)) if '/extrafanart' in base_url: jellyfin_path = path[1:] jellyfin_id = params.get('id') get_fanart(jellyfin_id, jellyfin_path, server) elif '/Extras' in base_url or '/VideoFiles' in base_url: jellyfin_path = path[1:] jellyfin_id = params.get('id') get_video_extras(jellyfin_id, jellyfin_path, server) elif mode == 'play': item = TheVoid('GetItem', { 'Id': params['id'], 'ServerId': server }).get() Actions(server).play(item, params.get('dbid'), params.get('transcode') == 'true', playlist=params.get('playlist') == 'true') elif mode == 'playlist': event('PlayPlaylist', {'Id': params['id'], 'ServerId': server}) elif mode == 'deviceid': client.reset_device_id() elif mode == 'reset': reset() elif mode == 'delete': delete_item() elif mode == 'refreshboxsets': event('SyncLibrary', {'Id': "Boxsets:Refresh"}) elif mode == 'nextepisodes': get_next_episodes(params['id'], params['limit']) elif mode == 'browse': browse(params.get('type'), params.get('id'), params.get('folder'), server) elif mode == 'synclib': event('SyncLibrary', {'Id': params.get('id')}) elif mode == 'updatelib': event('SyncLibrary', {'Id': params.get('id'), 'Update': True}) elif mode == 'repairlib': event('RepairLibrary', {'Id': params.get('id')}) elif mode == 'removelib': event('RemoveLibrary', {'Id': params.get('id')}) elif mode == 'repairlibs': event('RepairLibrarySelection') elif mode == 'updatelibs': event('SyncLibrarySelection') elif mode == 'removelibs': event('RemoveLibrarySelection') elif mode == 'addlibs': event('AddLibrarySelection') elif mode == 'addserver': event('AddServer') elif mode == 'login': event('ServerConnect', {'Id': server}) elif mode == 'removeserver': event('RemoveServer', {'Id': server}) elif mode == 'settings': xbmc.executebuiltin('Addon.OpenSettings(plugin.video.jellyfin)') elif mode == 'adduser': add_user() elif mode == 'updateserver': event('UpdateServer') elif mode == 'thememedia': get_themes() elif mode == 'managelibs': manage_libraries() elif mode == 'backup': backup() elif mode == 'restartservice': window('jellyfin.restart.bool', True) else: listing()
def __init__(self): global CONTENT_TYPE ''' Parse the parameters. Reroute to our service.py where user is fully identified already. ''' base_url = sys.argv[0] path = sys.argv[2] try: params = dict(urlparse.parse_qsl(path[1:])) except Exception: params = {} if 'content_type' in params: window('emby.plugin.content.type', params['content_type']) CONTENT_TYPE = params['content_type'] else: CONTENT_TYPE = window('emby.plugin.content.type') or None mode = params.get('mode') server = params.get('server') if server == 'None' or not server: server = None LOG.warn("path: %s params: %s", path, json.dumps(params, indent=4)) if '/extrafanart' in base_url: emby_path = path[1:] emby_id = params.get('id') get_fanart(emby_id, emby_path, server) elif '/Extras' in base_url or '/VideoFiles' in base_url: emby_path = path[1:] emby_id = params.get('id') get_video_extras(emby_id, emby_path, server) elif mode == 'play': window('emby.sync.pause.bool', True) window('emby.playlist.plugin.bool', True) try: objects.PlayPlugin(params, server).play('trailer' in base_url) except Exception as error: LOG.exception(error) if not xbmc.Player().isPlaying(): xbmc.Player().stop() xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem()) window('emby.sync.pause.bool', clear=True) window('emby.playlist.plugin', clear=True) elif mode =='playstrm': window('emby.sync.pause.bool', True) window('emby.playlist.plugin.bool', True) while not window('emby.playlist.play.bool'): xbmc.sleep(50) if window('emby.playlist.aborted.bool'): LOG.warn("[ playback aborted ]") break else: LOG.info("[ playback started ]") xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem()) window('emby.playlist.aborted', clear=True) window('emby.sync.pause', clear=True) window('emby.playlist.plugin', clear=True) elif mode == 'playsingle': window('emby.sync.pause.bool', True) window('emby.playlist.plugin.bool', True) try: objects.PlaySingle(params, server).play() except Exception as error: LOG.exception(error) if not xbmc.Player().isPlaying(): xbmc.Player().stop() xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem()) window('emby.sync.pause', clear=True) window('emby.playlist.plugin', clear=True) elif mode == 'playlist': event('PlayPlaylist', {'Id': params['id'], 'ServerId': server}) elif mode == 'photoviewer': xbmc.executebuiltin('ShowPicture(%s/emby/Items/%s/Images/Primary)' % (Emby(server)['auth/server-address'], params['id'])) elif mode == 'deviceid': client.reset_device_id() elif mode == 'reset': reset() elif mode == 'delete': delete_item() elif mode == 'refreshboxsets': event('SyncLibrary', {'Id': "Boxsets:Refresh"}) elif mode == 'nextepisodes': get_next_episodes(params['id'], params['limit']) elif mode == 'browse': browse(params.get('type'), params.get('id'), params.get('folder'), server) elif mode == 'synclib': event('SyncLibrary', {'Id': params.get('id')}) elif mode == 'updatelib': event('SyncLibrary', {'Id': params.get('id'), 'Update': True}) elif mode == 'repairlib': event('RepairLibrary', {'Id': params.get('id')}) elif mode == 'removelib': event('RemoveLibrary', {'Id': params.get('id')}) elif mode == 'repairlibs': event('RepairLibrarySelection') elif mode == 'updatelibs': event('SyncLibrarySelection') elif mode == 'removelibs': event('RemoveLibrarySelection') elif mode == 'addlibs': event('AddLibrarySelection') elif mode == 'connect': event('EmbyConnect') elif mode == 'addserver': event('AddServer') elif mode == 'login': event('ServerConnect', {'Id': server}) elif mode == 'removeserver': event('RemoveServer', {'Id': server}) elif mode == 'settings': xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)') elif mode == 'adduser': add_user(params.get('permanent') == 'true') elif mode == 'checkupdate': event('CheckUpdate') elif mode == 'resetupdate': event('ResetUpdate') elif mode == 'updateserver': event('UpdateServer') elif mode == 'thememedia': get_themes() elif mode == 'managelibs': manage_libraries() elif mode == 'texturecache': cache_artwork() elif mode == 'backup': backup() elif mode == 'restartservice': window('emby.restart.bool', True) elif mode == 'patchmusic': event('PatchMusic', {'Notification': True}) elif mode == 'changelog': changelog() elif mode == 'setssl': event('SetServerSSL', {'Id': server}) else: listing()
from app.preprocessor.collectionprocessor import cp_run import os import sys import database collection_name = "articles" if len(sys.argv) > 1 and sys.argv[1]: collection_name = sys.argv[1] collection_dir = os.path.join("tests", "data", collection_name) extension = ".xml" structure_file = os.path.join(collection_dir, "structure.json") database.reset() project = Project() project.save() user = User(email="test", password="******") user.add_project(project) user.save() files = [ f for f in os.listdir(collection_dir) if os.path.isfile(os.path.join(collection_dir, f)) ] for file_name in files: if os.path.splitext(file_name)[1] == extension:
def call(self): database.reset(self.sid) return {"success": "true"}
def echo_all(updates): global status for update in updates["result"]: text = update["message"]["text"] chat = update["message"]["chat"]["id"] username = update["message"]["from"]["first_name"] check_mode_change = (status[username] == 10) check_reason = (status[username] >= 1 and status[username] <= 6) prev_status = status[username] status[username] = 0 try: username2 = database.get_username2() text = text.lower() # reset calendar if "reset" == text: database.reset("Taehee") return # when he want to change back calendar to his if check_mode_change and check_yes(text): database.update_mode(username, 1) msg = "Okay, I changed." send_message(msg, chat) return # when he wants to check her emotions if "how is she" in text: if "now" in text: emotion = database.get_current_emotion(username2) if emotion == "": msg = "I don't know.. She didn't tell me how she is today." send_message(msg, chat) else: msg = "She is {}. ".format( emotion) + emotion_to_emoji[emotion] send_message(msg, chat) check_calendar(username, chat) else: emotions = database.get_today_emotions(username2) emots = [] for e in emotions: emotion = e['emotion'] if emotion == "": continue if len(emots) == 0 or emots[-1] != emotion: emots.append(emotion) if len(emots) == 0: msg = "I don't know.. She didn't tell me how she is today." send_message(msg, chat) return elif len(emots) == 1: msg = "She is {}. ".format( emots[0]) + emotion_to_emoji[emots[0]] else: msg = "She was {}, but {} now. ".format( emots[-2], emots[-1]) + emotion_to_emoji[emots[-1]] send_message(msg, chat) check_calendar(username, chat) return # when he/she explains the reason of the feeling if check_reason and "because" in text: database.update_reason(username, text) msg = group_to_response[prev_status].format(username) send_message(msg, chat) return # when he/she talks about his/her emotion for emotion in emotion_to_emoji.keys(): if emotion in text: # when he asks why she felt like that if "why" in text and "she" in text: msg = database.get_reason(username2, emotion) send_message(msg, chat) return group = emotion_to_group[emotion] database.add_emotion(username, emotion, group) msg = group_to_msg[group].format( emotion) + emotion_to_emoji[emotion] send_message(msg, chat) status[username] = emotion_to_group[emotion] return if text == "hi" or "hi " in text or "kelly" in text: msg = "Hi, {}. How are you?".format(username) keyboard = build_keyboard() send_message(msg, chat, keyboard) else: msg = update["message"]["text"] send_message(msg, chat) except Exception as e: print(e)
from app.models import * from database import reset import pdb reset() p = Project(name="test") w = Word(word="foo") w2 = Word(word="bar") w3 = Word(word="mar") s = Sentence(text="foo bar") Project.active_project = p s.add_word(w) print(w.sentences) p2 = Project(name="test2") s2 = Sentence(text="foo mar") Project.active_project = p2 s2.add_word(w) print(w.sentences) print("\n==============\n") se = Sequence(sequence="foo bar") se2 = Sequence(sequence="foo mar")
from app.preprocessor.collectionprocessor import cp_run import os import sys import database collection_name = "articles" if len(sys.argv) > 1 and sys.argv[1]: collection_name = sys.argv[1] collection_dir = os.path.join("tests", "data", collection_name) extension = ".xml" structure_file = os.path.join(collection_dir, "structure.json") database.reset() project = Project() project.save() user = User(email="test", password="******") user.add_project(project) user.save() files = [f for f in os.listdir(collection_dir) if os.path.isfile(os.path.join(collection_dir, f))] for file_name in files: if os.path.splitext(file_name)[1] == extension: document_file = DocumentFile(path = os.path.join(collection_dir, file_name))
def process(self, collection_dir, docstruc_filename, filename_extension, start_from_scratch): """ This function relies on several methods to: 1. Set up the database if necessary 2. Extract metadata, populate the narratives, sentences, and paragraphs tables 3. Process the sentences by tokenizing and indexing the words 4. Process the sentences by performing grammatical parsing structure extractor: - splits paragraph into sentences - creates Sentence object - adds Project to Sentence - adds Properties to Sentence - adds Sentence to Unit (which may also be a Document) document parser: -calls stringproc.parse on each Sentence stringproc.parse: - parses text with CoreNLP - adds Words to Sentence - adds Dependencies to Sentence - calls sequenceproc.process on each Sentence sequenceproc.process: - adds Sequences to Sentence :param str collection_dir: The directory whose files should be processed. :param str docstructure_file_name: The name of the JSON file that describes the structure in the document files. :param str file_name_extension: Files with this extension will be parsed as documents. :param boolean start_from_scratch: If true, then the tables in the database will be recreated. """ Base.commit_on_save = False # Set up database if necessary if start_from_scratch is True: database.reset() self.project.status = Project.STATUS_PREPROCESSING self.project.save() # Extract metadata, populate documents, sentences, and doc structure # tables if not "true" in logger.get(self.project, "finished_recording_text_and_metadata"): self.project_logger.info("Extracting document text and metadata") self.extract_record_metadata(collection_dir, docstruc_filename, filename_extension) # Parse the documents if ((app.config["GRAMMATICAL_PROCESSING"] or (app.config["WORD_TO_WORD_SIMILARITY"] and app.config["PART_OF_SPEECH_TAGGING"]) ) and not "true" in logger.get(self.project, "finished_grammatical_processing").lower()): self.parse_documents() self.project.status = Project.STATUS_DONE self.project.save() self.project_logger.info("Finished.")
def __init__(self): ''' Parse the parameters. Reroute to our service.py where user is fully identified already. ''' base_url = sys.argv[0] path = sys.argv[2] try: params = dict(urlparse.parse_qsl(path[1:])) except Exception: params = {} mode = params.get('mode') server = params.get('server') if server == 'None': server = None LOG.warn("path: %s params: %s", path, json.dumps(params, indent=4)) if '/extrafanart' in base_url: emby_path = path[1:] emby_id = params.get('id') get_fanart(emby_id, emby_path, server) elif '/Extras' in base_url or '/VideoFiles' in base_url: emby_path = path[1:] emby_id = params.get('id') get_video_extras(emby_id, emby_path, server) elif mode == 'play': item = TheVoid('GetItem', {'Id': params['id'], 'ServerId': server}).get() Actions(server).play(item, params.get('dbid'), params.get('transcode') == 'true', playlist=params.get('playlist') == 'true') elif mode =='playstrm': while not window('emby.playlist.play.bool'): xbmc.sleep(50) if window('emby.playlist.aborted.bool'): LOG.info("[ playback aborted ]") break else: LOG.info("[ playback started ]") xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem()) window('emby.playlist.aborted', clear=True) elif mode == 'playsimple': from helper import playsimple playsimple.PlaySimple(params, server).play() elif mode == 'playlist': event('PlayPlaylist', {'Id': params['id'], 'ServerId': server}) elif mode == 'deviceid': client.reset_device_id() elif mode == 'reset': reset() elif mode == 'delete': delete_item() elif mode == 'refreshboxsets': event('SyncLibrary', {'Id': "Boxsets:Refresh"}) elif mode == 'nextepisodes': get_next_episodes(params['id'], params['limit']) elif mode == 'browse': browse(params.get('type'), params.get('id'), params.get('folder'), server) elif mode == 'synclib': event('SyncLibrary', {'Id': params.get('id')}) elif mode == 'updatelib': event('SyncLibrary', {'Id': params.get('id'), 'Update': True}) elif mode == 'repairlib': event('RepairLibrary', {'Id': params.get('id')}) elif mode == 'removelib': event('RemoveLibrary', {'Id': params.get('id')}) elif mode == 'repairlibs': event('RepairLibrarySelection') elif mode == 'updatelibs': event('SyncLibrarySelection') elif mode == 'removelibs': event('RemoveLibrarySelection') elif mode == 'addlibs': event('AddLibrarySelection') elif mode == 'connect': event('EmbyConnect') elif mode == 'addserver': event('AddServer') elif mode == 'login': event('ServerConnect', {'Id': server}) elif mode == 'removeserver': event('RemoveServer', {'Id': server}) elif mode == 'settings': xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)') elif mode == 'adduser': add_user(params.get('permanent') == 'true') elif mode == 'checkupdate': event('CheckUpdate') elif mode == 'updateserver': event('UpdateServer') elif mode == 'thememedia': get_themes() elif mode == 'managelibs': manage_libraries() elif mode == 'texturecache': cache_artwork() elif mode == 'backup': backup() elif mode == 'restartservice': window('emby.restart.bool', True) elif mode == 'patchmusic': event('PatchMusic', {'Notification': True}) else: listing()
def reset(hard=False): database.reset(hard) botmanager.reset(hard)