Exemplo n.º 1
0
    def OnIdle(self, event = None):
        '''Idle UI handler'''
        # Save window settings
        settings.saveSettings()

        # Handle comms receive logic
        self.CommsReceive()
Exemplo n.º 2
0
 def OnClose(self, event):
     """Event handler for closing."""
     try:
         # Save any unsaved settings
         settings.saveSettings(self._controller)
     except Exception, msg:
         self._debug("Error during shutdown", msg)
Exemplo n.º 3
0
 def OnClose(self, event):
     '''Event handler for closing.'''
     try:
         # Save any unsaved settings
         settings.saveSettings()
     except Exception, msg:
         logger.error(msg)
         logger.error('Error during shutdown')
Exemplo n.º 4
0
    def guiVarsToSave():
        for x in cfg.config["strings"]:
            cfg.config["strings"][x] = guiVars[x].get()
        for x in cfg.config["variables"]:
            cfg.config["variables"][x] = str(guiVars[x].get())
        for x in cfg.config["intvars"]:
            cfg.config["intvars"][x] = str(guiVars[x].get())

        cfg.saveSettings()
        return True
Exemplo n.º 5
0
    def _finishQuit(self, result=None):
        debug("In second stage shutdown")
        if self.window:
            self.window.destroy()

        # seems to be a bug, but we need to clean up the threadpool
        if reactor.threadpool is not None:
            reactor.threadpool.stop()
        try:
            reactor.stop()
        except twisted.internet.error.ReactorNotRunning:
            debug("Reactor wasn't running, so couldn't stop it")

        if self.settings:
            settings.saveSettings(self.settings)

        debug("Finished shutdown, goodbye")
Exemplo n.º 6
0
 def doEnd(self,outcome):
     bs.playMusic(None)
     if self._score2 > 500:
         outcome = 'defeat'
         self._score2 = 0
     self.end(results={'outcome':outcome,'score':self._score2,'playerInfo':self.initialPlayerInfo},delay = 3000)
     
     if outcome == 'defeat':
         self._bots.finalCelebrate()
         self.fadeToRed()
     elif outcome == 'victory':
         tint = bs.getSharedObject('globals').tint
         bsUtils.animateArray(bs.getSharedObject('globals'),"tint",3,{0:tint,1000:(1.4,1.4,1.4)})
         self.cameraFlash()
         import bsAchievement
         bsAchievement._awardLocalAchievement('Boss')
         import settings
         settings.bolt = True
         settings.duck = True
         settings.saveSettings()
Exemplo n.º 7
0
        sys.exit(0)

    connectionSettings = settings.getConnection(server)

    if not connectionSettings:
        if server == 'main' or server == 'ptr':
            legacyConfig = settings.getLegacySettings()
            if legacyConfig:
                if raw_input("Upgrade settings file to the new format? (y/n) ") != "y":
                    sys.exit(-1)
                settings.addConnection('main', legacyConfig['screeps_username'], legacyConfig['screeps_password'])
                config = settings.getSettings()
                config['smooth_scroll'] = legacyConfig['smooth_scroll']
                config['max_scroll'] = legacyConfig['max_scroll']
                config['max_history'] = legacyConfig['max_history']
                settings.saveSettings(config)
                connectionSettings = settings.getConnection(server)

    if not connectionSettings:
        if server is 'main':
            host = 'screeps.com'
            secure = True
        else:
            host = raw_input("Host: ")
            secure = raw_input("Secure (y/n) ") == "y"
        username = raw_input("Username: "******"Password: ")
        settings.addConnection(server, username, password, host, secure)


    ScreepsInteractiveConsole(server)
Exemplo n.º 8
0
 def saveSettings(self):
     settings.saveSettings(self.settings, "quester")
Exemplo n.º 9
0
 def saveSettings(self):
     settings.saveSettings(self.settings, "grinder")
Exemplo n.º 10
0
        settings.removeConnection(server)
        sys.exit(0)

    connectionSettings = settings.getConnection(server)

    if not connectionSettings:
        if server == 'main' or server == 'ptr':
            legacyConfig = settings.getLegacySettings()
            if legacyConfig:
                if input("Upgrade settings file to the new format? (y/n) ") == "y":
                    settings.addConnection('main', legacyConfig['screeps_username'], legacyConfig['screeps_password'])
                    config = settings.getSettings()
                    config['smooth_scroll'] = legacyConfig['smooth_scroll']
                    config['max_scroll'] = legacyConfig['max_scroll']
                    config['max_history'] = legacyConfig['max_history']
                    settings.saveSettings(config)
                    connectionSettings = settings.getConnection(server)

    if not connectionSettings:
        if server is 'main':
            host = 'screeps.com'
            secure = True
        else:
            host = input("Host: ")
            secure = input("Secure (y/n) ") == "y"
        username = input("Username: "******"Password: ")
        settings.addConnection(server, username, password, host, secure)

    if server == 'main' and 'token' not in connectionSettings:
        settings.addConnection('main', connectionSettings['username'], connectionSettings['password'])
Exemplo n.º 11
0
    def on_custom_mindstorms_gadget_control(self, directive):
        try:
            payload = json.loads(directive.payload.decode("utf-8"))
            print("Control payload: {}".format(payload), file=sys.stderr)
            controlType = payload["type"]

            if controlType == "print":
                print("Printing a word.")
                if not settings.getDialogMode():
                    p.startPrinting()
                    t.printText(payload["word"])
                    p.finishPrinting()

            if controlType == "printList":
                print("Printing a list.")
                itemList = json.loads(payload["items"])
                if not settings.getDialogMode():
                    p.startPrinting()
                    for item in itemList:
                        draw.listItem(item)
                    p.finishPrinting()

            if controlType == "giftTags":
                print("Printing gift tags.")
                itemList = json.loads(payload["items"])
                sender = payload["sender"]
                if not settings.getDialogMode():
                    p.startPrinting()

                    for item in itemList:
                        #                        print( "Current Y Position: {}".format( p.CurrentPositionY ), file=sys.stderr )
                        #                        print( "Gift tag height: {}".format( draw.giftTagHeight() ), file=sys.stderr )
                        #                        print( "Page height: {}".format( p.PageHeight ), file=sys.stderr )
                        if (p.CurrentPositionY - draw.giftTagHeight() <
                                p.PageHeight):
                            p.newSheet()
                        draw.giftTag(item, sender)

                    p.finishPrinting()

            if controlType == "mindstorms":
                print("Drawing the EV3 logo.")
                if not settings.getDialogMode():
                    p.startPrinting()
                    draw.ev3Logo(800)
                    p.finishPrinting()

            if controlType == "calibrate":
                print("Calibrating the printer.")
                if not settings.getDialogMode():
                    p.calibrate()

            if controlType == "setTextSize":
                print("Setting the text size.")
                settings.setTextSize(payload["size"] * 8)
                t.updateMetrics(settings.getTextSize())
                settings.saveSettings()

            if controlType == "getTextSize":
                print("Getting the text size.")
                self._send_event("TextSize",
                                 {'size': settings.getTextSize() / 8})

            if controlType == "dialogMode":
                enable = payload["enable"]
                if enable == "on":
                    print("Entering dialog mode.")
                    settings.setDialogMode(True)
                else:
                    print("Exiting dialog mode.")
                    settings.setDialogMode(False)

        except KeyError:
            print("Missing expected parameters: {}".format(directive),
                  file=sys.stderr)
Exemplo n.º 12
0
def main():

    # Load settings
    filepath_settings = 'C:/DISCHARGEDB/code/data/settings.json'
    settings = initSettings()
    saveSettings(settings, filepath_settings)
    settings = fillSettingsTags(loadSettings(filepath_settings))

    # Downlaod new images from ag mednet
    discharge = DISCHARGEDB(database=settings['database'])
    #discharge.download_images(settings)
    #discharge.update_images(settings)

    discharge.truncateTable(tablename='dicom')
    discharge.update_dicom(settings)

    ### Update agmednet reports ###
    discharge = DISCHARGEDB(host="127.0.0.1",
                            port='3306',
                            user="******",
                            password="******",
                            database=settings['database'])
    discharge.update_agmednet_01(settings)
    discharge.update_agmednet_02(settings)

    discharge = DISCHARGEDB(host="127.0.0.1",
                            port='3306',
                            user="******",
                            password="******",
                            database=settings['database'])
    rs = discharge.truncateTable('agmednet_02')
    discharge.update_agmednet_02(settings)
    df = discharge.getTable('agmednet_02')

    df = discharge.getTable('agmednet_01')

    #### Execute sript #####
    discharge = DISCHARGEDB(host="127.0.0.1",
                            port='3306',
                            user="******",
                            password="******",
                            database=settings['database'])
    table = discharge.getTable('agmednet_01')
    discharge.truncateTable('agmednet_01')
    discharge.truncateTable('agmednet_02')
    discharge.connectSQL()

    table = discharge.getTable('agmednet_01')
    table = discharge.getTable('agmednet_01')

    self = db
    mysql_path = 'mysql://' + self.user + ':' + self.password + '@' + self.host + '/' + self.database + '?charset=utf8'
    sqlEngine = create_engine(mysql_path)
    df = pd.read_sql("SELECT * FROM agmednet_01", sqlEngine)

    ### Reset autoincrement
    db = DISCHARGEDB(host="127.0.0.1",
                     port='3306',
                     user="******",
                     password="******",
                     database=settings['database'])
    db.connectSQL()
    db.resetAutoIncrement()

    #db.createDB()
    db.initDB(settings)
    db.executeScript(
        fip_script=
        'H:/cloud/cloud_data/Projects/DISCHARGEDB/src/scripts/set_primary_key.sql',
        replace=('TABLE_VAR', 'v_a06_docu_hosp'))

    result = db.executeSQL('SELECT * FROM dischargedb3.site;')
    db.sas7bdatTosql()
    db.closeSQL()

    filename = 'v_a01_fu_staff'

    db = DISCHARGEDB(database=settings['database'])
    db.connectSQL()
    db.executeSQL('ALTER TABLE ' + filename + ' ADD PRIMARY KEY index')

    command = "ALTER TABLE `dischargedb`.`v_a03_ses_staff` CHANGE COLUMN `index` `index` BIGINT NOT NULL ,"

    cursor = db.db.cursor()
    cursor.execute(command)
    result = cursor.fetchall()

    db = DISCHARGEDB(database=settings['database'])
    db.connectSQL()
    #command = "ALTER TABLE `dischargedb`.`v_a02_fu_questf_sub01` CHANGE COLUMN `index` `index` BIGINT NULL ,ADD PRIMARY KEY (`index`);;"
    command = "ALTER TABLE dischargedb.v_a03_ses_staff CHANGE COLUMN index index BIGINT NOT NULL"
    db.executeSQL(command)

    ##############################

    reader = SAS7BDAT(
        'H:/cloud/cloud_data/Projects/DISCHARGEDB/data/tmp/ecrf/v_g02_ct_reading_a.sas7bdat',
        skip_header=False)
    df1 = reader.to_data_frame()
    for i in range(len(reader.columns)):
        f = reader.columns[i].format
        print('format:', f)

    c = reader.columns[10]

    fip = 'H:/cloud/cloud_data/Projects/DISCHARGEDB/data/tmp/ecrf/v_a01_fu_staff.sas7bdat'
    df = pd.read_sas(fip, format='sas7bdat', encoding='iso-8859-1')
    df.to_sql(con=con,
              name='table_name_for_df',
              if_exists='replace',
              flavor='mysql')

    mysql_path = 'mysql://*****:*****@localhost/?charset=utf8'
    engine = create_engine(mysql_path, encoding="utf-8", echo=False)
    # with engine.connect() as con:
    # con.execute("use dischargedb3; drop table if exists " + name + ";")
    # df = pd.read_excel(path)
    # df.to_sql(name, engine, index=False)

    fip = 'H:/cloud/cloud_data/Projects/DISCHARGEDB/data/tables/sas/v_a02_fu_questf_sub01.sas7bdat'
    df = pd.read_sas(fip, format='sas7bdat', encoding='iso-8859-1')

    with engine.connect() as con:
        #con = engine.connect()
        con.execute("use dischargedb3;")
    df.to_sql('table6', engine, index=False)

    df = pd.read_excel(
        'H:/cloud/cloud_data/Projects/DISCHARGEDB/data/tables/xlsx/discharge_ecrf_01092020.xlsx',
        sheet_name='Sheet1',
        index_col=0)