def __init__(self, *args, **kwargs): Tk.__init__(self, *args, **kwargs) self.config_manager = ConfigManager() temp_translator_object = TranslatorManager() for provider_defintion in self.config_manager.get_providers()['api_providers']: temp_translator_object.add_translation_service(provider_defintion['name'], provider_defintion['service'], provider_defintion['token']) self.title('Tongues Translator') self.geometry(DEFAULT_WINDOW_SIZE) self.call('wm', 'iconphoto', self._w, PhotoImage(file='media/icon.png')) self.sidebar = SideBar() self.pages = {} self.add_page('Instant Translate', InstantTranslatePage(self, translator=temp_translator_object)) self.add_page('Text File Translate', TextFileTranslate(self, translator=temp_translator_object)) self.mainloop()
class TonguesTranslator(Tk): ''' Acts as the main window for the application, draws upon components in gui to build the interface ''' def __init__(self, *args, **kwargs): Tk.__init__(self, *args, **kwargs) self.config_manager = ConfigManager() temp_translator_object = TranslatorManager() for provider_defintion in self.config_manager.get_providers()['api_providers']: temp_translator_object.add_translation_service(provider_defintion['name'], provider_defintion['service'], provider_defintion['token']) self.title('Tongues Translator') self.geometry(DEFAULT_WINDOW_SIZE) self.call('wm', 'iconphoto', self._w, PhotoImage(file='media/icon.png')) self.sidebar = SideBar() self.pages = {} self.add_page('Instant Translate', InstantTranslatePage(self, translator=temp_translator_object)) self.add_page('Text File Translate', TextFileTranslate(self, translator=temp_translator_object)) self.mainloop() def add_page(self, name, page): ''' add a page to the application. If no pages currently exist, the page will also be shown. Args: name (str): The name of the page, used to identify the page page (obj): A tkinter object containing the page to be added ''' self.pages[name] = page self.sidebar.add_button('btn_' + name, name, TOP) self.sidebar.buttons['btn_' + name].bind_function(lambda event: (self.show_page(name))) if len(self.pages) == 1: self.show_page(name) def show_page(self, name): ''' Shows a named page Args: name (str): the name of the page to be shown ''' self.sidebar.focus_button('btn_' + name) self.hide_all_pages() self.pages[name].show() def hide_all_pages(self): ''' Hides all pages in TonguesTranslator window''' for key, page in self.pages.items(): page.hide()
def store_mysql_config(mysql_config): print('Storing mysql config of vendor management team') ConfigManager.write_config('vendor_mysql_config.json', mysql_config)
def read_resolv_config(): print('Reading resolv config vendor management servers') resolv_config = ConfigManager.read_config( 'vendor_server_resolv_config.json') return resolv_config
def read_mysql_config(): print('Reading mysql config of vendor management team') mysql_config = ConfigManager.read_config('vendor_mysql_config.json') return mysql_config
def store_resolv_config(resolv_config): print('Storing resolv config of all vendor management servers') ConfigManager.write_config('vendor_server_resolv_config.json', resolv_config)
while True: index = self.message.find(MessageMark.END_MARK) if index != -1: handle_part = self.message[:index] # Handle message Dispatcher.dispatch(self, handle_part) self.message = self.message[index+len(MessageMark.END_MARK):] else: break def handle_close(self): game_manager = OnlineManager.get_game_manager(self) if game_manager is not None: game_manager.is_running = False OnlineManager.remove_and_save_game_manager(self) print("closed client: %s"% (repr(self.addr))) self.close() def _input(): while(True): data0 = raw_input() #client.send(data0) ConfigManager.init() (host, port) = "127.0.0.1", 6500 # sys.argv[2:]; server = GameServer(host, port) asyncore.loop()
def store_mysql_config(mysql_config): print('Storing mysql config of inventory team') ConfigManager.write_config_to_json('inventory_mysql_config.json', mysql_config)
def read_mysql_config(): print('Reading mysql config of inventory team') mysql_config = ConfigManager.read_config_from_json( 'inventory_mysql_config.json') return mysql_config
"""The main file""" from config.config_manager import ConfigManager from libs.util import debug, warning system_config = ConfigManager() USE_APP = system_config["interface"]["use"] if USE_APP: from UI.server.app import app debug("Starting server") app.run(port=80) debug("Running server on \"http://localhost/\"") USE_CAMERA = system_config["camera"]["use"] if USE_CAMERA: from Camera.camera import Camera camera = Camera() USE_CAMERA_CONTOURS = system_config["camera"]["contours"] USE_CAMERA_OBJECTS = system_config["camera"]["objects"] if USE_CAMERA_CONTOURS: from Camera.scanner import ContourScanner contour_scanner = ContourScanner() if USE_CAMERA_OBJECTS: from Camera.scanner import CascadeScanner face_cascade_scanner = CascadeScanner( "./cascades/haarcascade_frontalface_default.xml") USE_GPIO = system_config["gpio"]["use"] if USE_GPIO: try:
def get_config_manager(self, config_file): return ConfigManager(config_file)
def store_mysql_config(mysql_config): print('Storing mysql config of logistics team') ConfigManager.write_config_to_xml('logistics_mysql_config.xml', mysql_config)
def read_logistics_rest_server_config(): print('Reading rest_server config of logistics team') rest_server_config = ConfigManager.read_config_from_xml( 'logistics_rest_server.xml') return rest_server_config
def read_mysql_config(): print('Reading mysql config of logistics team') mysql_config = ConfigManager.read_config_from_xml( 'logistics_mysql_config.xml') return mysql_config
def store_logistics_rest_server_config(rest_server_config): print('Storing rest_server config of logistics team') ConfigManager.write_config_to_xml('logistics_rest_server.xml', rest_server_config)
def read_mysql_config(): print('Reading mysql config of logistics team') mysql_config = ConfigManager.read_config('logistics_mysql_config.json') return mysql_config