Exemple #1
0
    def __detect_client_timezone(self, conn):
        """This is run on the very first connection."""

        if self.__client_timezone is not None:
            return

        _log.debug('trying to detect timezone from system')
        # we need gmDateTime to be initialized
        if gmDateTime.current_local_iso_numeric_timezone_string is None:
            gmDateTime.init()
        tz_candidates = [gmDateTime.current_local_timezone_name]
        try:
            tz_candidates.append(os.environ['TZ'])
        except KeyError:
            pass
        expanded_tzs = []
        for tz in tz_candidates:
            expanded = self.__expand_timezone(conn, timezone=tz)
            if expanded != tz:
                expanded_tzs.append(expanded)
        tz_candidates.extend(expanded_tzs)
        _log.debug('candidates: %s', tz_candidates)
        # find best among candidates
        found = False
        for tz in tz_candidates:
            if self.__validate_timezone(conn=conn, timezone=tz):
                self.__client_timezone = tz
                self.__SQL_set_client_timezone = 'SET timezone TO %(tz)s'
                found = True
                break
        if not found:
            self.__client_timezone = gmDateTime.current_local_iso_numeric_timezone_string
            self.__SQL_set_client_timezone = 'set time zone interval %(tz)s hour to minute'
        _log.info('client system timezone detected as equivalent to [%s]',
                  self.__client_timezone)
Exemple #2
0
if __name__ == "__main__":

    if len(sys.argv) < 2:
        sys.exit()

    if sys.argv[1] != 'test':
        sys.exit()

#	from Gnumed.pycommon import gmLog2
#	from Gnumed.pycommon import gmI18N
    from Gnumed.pycommon import gmDateTime
    #	from Gnumed.business import gmPerson
    from Gnumed.business import gmPraxis

    #	gmI18N.activate_locale()
    gmDateTime.init()

    def test_default_address():
        bills = get_bills(pk_patient=12)
        first_bill = bills[0]
        print(first_bill.default_address)

    #--------------------------------------------------
    def test_me():
        print("--------------")
        me = cBillable(aPK_obj=1)
        fields = me.get_fields()
        for field in fields:
            print(field, ':', me[field])
        print("updatable:", me.get_updatable_fields())
        #me['vat']=4; me.store_payload()
Exemple #3
0
	dtos = []
#	dtos.extend(get_available_CCRdr_files_as_dtos(spool_dir = spool_dir))
	dtos.extend(get_available_kvks_as_dtos(spool_dir = spool_dir))
	dtos.extend(get_available_egks_as_dtos(spool_dir = spool_dir))

	return dtos

#============================================================
# main
#------------------------------------------------------------
if __name__ == "__main__":

	from Gnumed.pycommon import gmI18N

	gmI18N.activate_locale()
	gmDateTime.init()

	def test_vks():
		dtos = get_available_CCRdr_files_as_dtos(spool_dir = sys.argv[2])
		for dto in dtos:
			print(dto)

	def test_egk_dto():
		# test cKVKd_file object
		kvkd_file = sys.argv[2]
		print("reading eGK data from KVKd file", kvkd_file)
		dto = cDTO_eGK(filename = kvkd_file, strict = False)
		print(dto)
		for attr in true_egk_fields:
			print(getattr(dto, attr))