コード例 #1
0
async def on_ready():
    sentry_sdk.init(SENTRY_DSN, traces_sample_rate=1.0)
    connect(DATABASE_URL)
    await bot.change_presence(activity=discord.Game(f"{prefix}help"))
    print("We are online!")
    print("Name: {}".format(bot.user.name))
    print("ID: {}".format(bot.user.id))
コード例 #2
0
def main():
    logging.info("pyOffer version %s started at %s", version, datetime.now())
    locale_set = locale.setlocale(locale.LC_ALL, '')
    logging.info("System locale: %s", locale_set)
    app = QApplication(sys.argv)
    app.setOrganizationName("KonserwSoft")
    app.setApplicationName("pyOffer")

    lang = QLocale.system().name()[0:2]
    logging.info("Loading translation for: %s", lang)
    translator = QTranslator()
    if translator.load(f"translations/{lang}"):
        app.installTranslator(translator)
        logging.info("Loaded translations from: %s", f"translations/{lang}")
    else:
        logging.warning("Failed to load translations from: %s",
                        f"translations/{lang}")

    settings = QSettings()
    settings.beginGroup("database")
    host_name = settings.value("host_name", "127.0.0.1")
    port = int(settings.value("port", "5432"))
    database_name = settings.value("database_name", "koferta_test")
    user_name = settings.value("user_name", "postgres")
    password = settings.value("password", "docker")
    settings.endGroup()
    try:
        logging.info("DB host name: %s", host_name)
        logging.info("DB port: %s", port)
        logging.info("DB database name: %s", database_name)
        logging.info("DB user name: %s", user_name)
        database.connect(host_name, database_name, user_name, password, port)
    except RuntimeError as e:
        QMessageBox.critical(
            None, app.tr("Database connection failed"),
            app.tr(f"Driver error: {e.args[1]}\nDatabase error: {e.args[2]}"))
        return str(e)
    user_dialog = UserSelectionDialog.make()
    if user_dialog.exec_() == QDialog.Accepted:
        logging.debug("User dialog accepted")
        user = User.from_sql_record(user_dialog.chosen_user_record)
        logging.info("Chosen user: %s", user)
        main_window = MainWindow(user)
        main_window.show()
        return app.exec_()
    logging.info("User hasn't been chosen - exiting")
    return 0
コード例 #3
0
ファイル: host_server.py プロジェクト: KajaBraz/ChatBox
def register():
    if request.method == 'POST':
        login = request.form.get('user_login')
        password = request.form.get('user_password')
        conn = connect(db_name, db_login, db_password)
        add_user(login, password, conn)
        return f'You are now successfully registered!'
    return render_template('registration.html')
コード例 #4
0
ファイル: tests.py プロジェクト: gilsondev/webapp
	def tearDown(self):
		db = database.connect(self.dbname)
		db.drop_database(self.dbname)	
コード例 #5
0
ファイル: app.py プロジェクト: mtlee/trans-health
def before_request():
    g.db = database.connect('trans-health.db')
コード例 #6
0
async def create_db_client():
    database.connect()
コード例 #7
0
def build ():
    s = database.connect('trans-health.db')

    humana = database.Company(name='Humana')
    bcbs = database.Company(name='Blue Cross and Blue Shield')
    cigna = database.Company(name='Cigna')
    amerigroup = database.Company(name='Amerigroup')

    s.add(humana)
    s.add(bcbs)
    s.add(cigna)
    s.add(amerigroup)

    cigna = database.Plan(company=cigna,
                          name='myCigna Health Savings',
                          state='TX',
                          color_code='bronze',
                          medicaid=False)

    s.add(cigna)
    s.add(database.Plan(company=humana,
                        name='Humana Basic 6600',
                        state='TX',
                        color_code='catastrophic',
                        medicaid=False))
    s.add(database.Plan(company=humana,
                        name='blue Advantage Bronze HMO',
                        state='TX',
                        color_code='bronze',
                        medicaid=False))
    s.add(database.Plan(company=humana,
                        name='Humana Bronze 6300',
                        state='TX',
                        color_code='bronze',
                        medicaid=False))
    s.add(database.Plan(company=bcbs,
                        name='Blue Advantage Gold HMO 002',
                        state='TX',
                        color_code='gold',
                        medicaid=False))
    s.add(database.Plan(company=amerigroup,
                        name='STAR Medicaid',
                        state='TX',
                        color_code='not-present',
                        medicaid=True))

    s.add(database.CoverageStatement(date=datetime.date(2015, 8, 1),
                                     plan=cigna,
                                     service_type="medication",
                                     covered='yes'))
    s.add(database.CoverageStatement(date=datetime.date(2015, 8, 3),
                                     plan=cigna,
                                     service_type="medication",
                                     covered='yes'))
    s.add(database.CoverageStatement(date=datetime.date(2015, 8, 5),
                                     plan=cigna,
                                     service_type="medication",
                                     covered='unknown'))
    s.add(database.CoverageStatement(date=datetime.date(2014, 1, 10),
                                     plan=cigna,
                                     service_type="medication",
                                     covered='no'))
    s.add(database.CoverageStatement(date=datetime.date(2015, 8, 1),
                                     plan=cigna,
                                     service_type="surgery",
                                     covered='unknown'))
    s.add(database.CoverageStatement(date=datetime.date(2015, 8, 3),
                                     plan=cigna,
                                     service_type="surgery",
                                     covered='unknown'))
    s.add(database.CoverageStatement(date=datetime.date(2015, 8, 5),
                                     plan=cigna,
                                     service_type="surgery",
                                     covered='unknown'))
    s.add(database.CoverageStatement(date=datetime.date(2014, 1, 10),
                                     plan=cigna,
                                     service_type="surgery",
                                     covered='no'))

    s.add(database.Experience(date=datetime.date(2014, 12, 1),
                              age=36,
                              plan=cigna,
                              documented_gender='M',
                              service='Estradiol',
                              success=True))
    s.add(database.Experience(date=datetime.date(2015, 3, 1),
                              age=36,
                              plan=cigna,
                              documented_gender='M',
                              service='Estradiol',
                              success=True))
    s.add(database.Experience(date=datetime.date(2015, 6, 1),
                              age=36,
                              plan=cigna,
                              documented_gender='M',
                              service='Estradiol',
                              success=True))
    s.add(database.Experience(date=datetime.date(2015, 9, 1),
                              age=36,
                              plan=cigna,
                              documented_gender='M',
                              service='Estradiol',
                              success=True))
    s.add(database.Experience(date=datetime.date(2015, 12, 1),
                              age=37,
                              plan=cigna,
                              documented_gender='F',
                              service='Estradiol',
                              success=True))

    s.add(database.Experience(date=datetime.date(2014, 12, 1),
                              age=36,
                              plan=cigna,
                              documented_gender='M',
                              service='Spironolactone',
                              success=True))
    s.add(database.Experience(date=datetime.date(2015, 3, 1),
                              age=36,
                              plan=cigna,
                              documented_gender='M',
                              service='Spironolactone',
                              success=True))
    s.add(database.Experience(date=datetime.date(2015, 6, 1),
                              age=36,
                              plan=cigna,
                              documented_gender='M',
                              service='Spironolactone',
                              success=True))
    s.add(database.Experience(date=datetime.date(2015, 9, 1),
                              age=36,
                              plan=cigna,
                              documented_gender='M',
                              service='Spironolactone',
                              success=False))
    s.add(database.Experience(date=datetime.date(2015, 12, 1),
                              age=37,
                              plan=cigna,
                              documented_gender='F',
                              service='Spironolactone',
                              success=True))

    s.add(database.Experience(date=datetime.date(2015, 12, 1),
                              age=31,
                              plan=cigna,
                              documented_gender='F',
                              service='Facial Feminization',
                              success=True))

    s.commit()
コード例 #8
0
ファイル: app.py プロジェクト: sacsar/trans-health
def before_request():
    g.db = database.connect('trans-health.db')
コード例 #9
0
ファイル: stockbot.py プロジェクト: jacmarcx/StockBot
async def on_ready():
    sentry_sdk.init(SENTRY_DSN, traces_sample_rate=1.0)
    connect(DATABASE_URL)
    print("We are online!")
    print("Name: {}".format(bot.user.name))
    print("ID: {}".format(bot.user.id))