def main(): online = sys.argv[1] hdn = dockerHandler.Docker_handler() if (online): dk_server = dock_server(address=('localhost', 8082), handler=hdn) dk_server.run() else: db_handler.db_handler()
def _dummy_test(): handler = Docker_handler() grabber = db_handler.db_handler("") images = grabber.test_populate() deam = deamon.deamon(images, handler) deam.dummy_start() from_planner()
def __init__(self, ini="logs/sql_statements.ini", database="messages"): #Read bot.ini config = configparser.ConfigParser() config.read(ini) #Convert config to simple dict for ease of use: for section in config.sections(): for tup in config.items(section): self.sqls.update({tup[0]: tup[1]}) self.database = database self.handler = db_handler.db_handler()
def main(): handler = Docker_handler() grabber = db_handler.db_handler("") images = grabber.populate_from_dummy_db() commands = ['sleep 30', 'echo $PATH'] for c in images: out = handler.start_container(image=c, command="sleep 30", mem=4) print(out.id) print("-----------------") for k in handler.conts: cnt = handler.get_container(k) cnt.exec_run(commands[1])
def _process_event(self, event): status_ui = aiy.voicehat.get_status_ui() if event.type == EventType.ON_START_FINISHED: status_ui.status('ready') self._can_start_conversation = True aiy.voicehat.get_button().on_press(self._on_button_pressed) if sys.stdout.isatty(): print('Say "OK, Google" or press the button, then speak.' 'Press ctrl+C to quit...') elif event.type == EventType.ON_CONVERSATION_TURN_STARTED: self._can_start_conversation = False status_ui.status('listening') elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and event.args: print('You said: ', event.args['text']) text = event.args['text'].lower() db = db_handler() response = db.findResponse(text) if response: self._assistant.stop_conversation() self._text_assistant.assist("repeat after me " + response) # if 'ip address' in text: # self._assistant.stop_conversation() # ip_address = subprocess.check_output("hostname -I | cut -d' ' -f1", shell=True) # self._text_assistant.assist("repeat after me my IP address is %s" % ip_address.decode('utf-8')) elif event.type == EventType.ON_END_OF_UTTERANCE: status_ui.status('thinking') elif (event.type == EventType.ON_CONVERSATION_TURN_FINISHED or event.type == EventType.ON_CONVERSATION_TURN_TIMEOUT or event.type == EventType.ON_NO_RESPONSE): status_ui.status('ready') self._can_start_conversation = True elif event.type == EventType.ON_ASSISTANT_ERROR and event.args and event.args[ 'is_fatal']: sys.exit(1)
import db_handler obj = db_handler.db_handler() flag=True while flag: chk = input('i(insert)or s(select)or e(exit)\n>>') if chk == "i": name=input("name>>") age=input("age>>") obj.__insert__(name, age) elif chk =="s": obj.__select__() elif chk == "e": obj.__close__() flag=False
if parser.has_section(section): items = parser.items(section) for item in items: cf[item[0]] = item[1] else: raise Exception('{0} not found in the {1} file'.format( section, filename)) return cf #----------------------------------------------------------------------------------------------------- cf = read_config() bot = telebot.TeleBot(cf['token'], threaded=False) db = db_handler() #----------------------------------------------------------------------------------------------------- # Webhook bot.remove_webhook() time.sleep(1) bot.set_webhook(url="{}/{}".format(cf['url'], cf['secret'])) app = Flask(__name__) @app.route('/{}'.format(cf['secret']), methods=["POST"]) def webhook(): bot.process_new_updates( [telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
def before_request(): """instantiates a new database object and stores it as a global variable""" g.db = db_handler(DATABASE)
def full_test(): handler = Docker_handler() grabber = db_handler.db_handler("") images = grabber.populate_from_db() deam = deamon.deamon(images, handler) deam.start()
import concurrent.futures import time def __check_students(cabinets_lits): #test code print("THREAD, CAB LIST SIZE = ", len(cabinets_lits)) print(cabinets_lits) #raise Exception("Tobi pizda") return True if __name__ == '__main__': handler = db_handler() #tests #entity = [31, 20, '2006-01-01', 3] #handler.insert_row(db_tables.mephi_journal, entity) #print(handler.get_row_by_id(db_tables.mephi_journal, 4)) # cab = [['A-101', '213.24.32.15'], ['A-102', '213.24.32.16']] # handler.insert_rows(db_tables.cabinets, cab) #for entity in handler.get_all_rows(db_tables.mephi_journal): #print(entity) #for entity in handler.get_all_rows(db_tables.cabinets): #print(entity) #end of tests