예제 #1
0
파일: gmGuiWeb.py 프로젝트: ncqgm/gnumed
def GetLoginInfo(username=None, password=None, backend=None):
    # username is provided through the web interface
    # password is provided
    # we need the profile
    """convenience function for compatibility with gmLoginInfo.LoginInfo"""
    #if not self.cancelled:
    # FIXME: do not assume conf file is latin1 !
    #profile = self.__backend_profiles[self._CBOX_profile.GetValue().encode('latin1').strip()]
    #self.__backend_profiles = self.__get_backend_profiles()
    __backend_profiles = __get_backend_profiles()
    profile = __backend_profiles[backend.encode('utf8').strip()]

    _log.debug(u'backend profile "%s" selected', profile.name)
    _log.debug(u' details: <%s> on %s@%s:%s (%s, %s)', username,
               profile.database, profile.host, profile.port, profile.encoding,
               gmTools.bool2subst(profile.public_db, u'public', u'private'))
    #_log.debug(u' helpdesk: "%s"', profile.helpdesk)
    login = gmLoginInfo.LoginInfo(user=username,
                                  password=password,
                                  host=profile.host,
                                  database=profile.database,
                                  port=profile.port)
    #login.public_db = profile.public_db
    #login.helpdesk = profile.helpdesk
    return login
예제 #2
0
    def create_temp_categories(categories=['hospital']):
        print(
            "NEED TO CREATE TEMPORARY ORG_CATEGORY.\n\n ** PLEASE ENTER administrator login  : e.g  user 'gm-dbo' and  his password"
        )
        #get a admin login
        for i in range(0, 4):
            result, tmplogin = login_admin_user()
            if result:
                break
        if i == 4:
            print("Failed to login")
            return categories

        # and save it , for later removal of test categories.
        from Gnumed.pycommon import gmLoginInfo
        adminlogin = gmLoginInfo.LoginInfo(*tmplogin.GetInfo())

        #login as admin
        p = gmPG.ConnectionPool(tmplogin)
        conn = p.GetConnection("personalia")

        # use the last value + 1 of the relevant sequence, but don't increment it
        cursor = conn.cursor()

        failed_categories = []
        n = 1
        for cat in categories:
            cursor.execute("select last_value from dem.org_category_id_seq")
            [org_cat_id_seq] = cursor.fetchone()

            cursor.execute(
                "insert into dem.org_category(description, id) values('%s', %d)"
                % (cat, org_cat_id_seq + n))
            cursor.execute(
                "select id from dem.org_category where description in ('%s')" %
                cat)

            result = cursor.fetchone()
            if result == None or len(result) == 0:
                failed_categories.append(cat)
                print("Failed insert of category", cat)
                conn.rollback()
            else:
                conn.commit()
            n += 1

        conn.commit()
        p.ReleaseConnection('personalia')
        return failed_categories, adminlogin
예제 #3
0
    def GetLoginInfo(self):
        """convenience function for compatibility with gmLoginInfo.LoginInfo"""
        if self.cancelled:
            return None

        # FIXME: do not assume conf file is latin1 !
        profile = self.__backend_profiles[
            self._CBOX_profile.GetValue().strip()]
        _log.info('backend profile "%s" selected', profile.name)
        _log.info(' details: <%s> on %s@%s:%s (%s, %s)',
                  self._CBOX_user.GetValue(), profile.database, profile.host,
                  profile.port, profile.encoding,
                  gmTools.bool2subst(profile.public_db, 'public', 'private'))
        _log.info(' helpdesk: "%s"', profile.helpdesk)
        login = gmLoginInfo.LoginInfo(user=self._CBOX_user.GetValue(),
                                      password=self.pwdentry.GetValue(),
                                      host=profile.host,
                                      database=profile.database,
                                      port=profile.port)
        login.public_db = profile.public_db
        login.helpdesk = profile.helpdesk
        login.backend_profile = profile.name
        return login
예제 #4
0
	rcvr = 'user'
	gmPG.add_housekeeping_todo(reporter=by, receiver=rcvr, problem=problem, solution=solution, context=context, category=cat)
#===============================================================
# main
#---------------------------------------------------------------
if __name__ == '__main__':
	if _cfg is None:
		_log.Log(gmLog.lErr, 'need config file to run')
		sys.exit(1)
	# set encoding
	gmPG.set_default_client_encoding('latin1')
	# setup login defs
	auth_data = gmLoginInfo.LoginInfo(
		user = _cfg.get('database', 'user'),
		password = _cfg.get('database', 'password'),
		host = _cfg.get('database', 'host'),
		port = _cfg.get('database', 'port'),
		database = _cfg.get('database', 'database')
	)
	backend = gmPG.ConnectionPool(login = auth_data)
	# actually run the import
	try:
		import profile
		profile.run('run_import()', './profile.log')
	except Exception:
		_log.LogException('unhandled exception caught', sys.exc_info(), verbose=1)
		backend.StopListeners()
		sys.exit('aborting')
	backend.StopListeners()
	sys.exit(0)
예제 #5
0
$> python make-anon-lab_reqs <ldt-datei>"

This will generate lab requests for all sample IDs found
in <ldt-datei>. All requests will belong to Laborata
Testwoman.
"""
    sys.exit()


print "accessing patient Laborata Testwoman"
# set encoding
gmPG.set_default_client_encoding('latin1')
# setup login defs
auth_data = gmLoginInfo.LoginInfo(user='******',
                                  passwd='any-doc',
                                  host='hherb.com',
                                  port=5432,
                                  database='gnumed')
backend = gmPG.ConnectionPool(login=auth_data)

pat_data = {'lastnames': 'Testwoman', 'firstnames': 'Laborata', 'gender': 'f'}
searcher = gmPersonSearch.cPatientSearcher_SQL()
pat_ids = searcher.get_patient_ids(search_dict=pat_data)

if len(pat_ids) == 0:
    print "cannot find Laborata Testwoman"
    sys.exit()
if len(pat_ids) > 1:
    print "more than one patient for Laborata Testwoman"
    sys.exit()