filename = conf_dir + "moneda.dat" try: archivo = open(filename, "r") rates = json.load(archivo) except urllib.error.URLError: # Failed to load json file currency = True if not isinstance(rates["date"], int): # Old version exchange rates format, force upgrade currency = True if currency: # Try to retrieve exchange rates from yahoo try: firstrun.getrates(conf_dir + "moneda.dat") except (urllib.error.URLError, urllib.error.HTTPError) as e: # Internet error, get hardcoded exchanges from pychemqt distribution # Possible outdated file, try to update each some commits origen = os.path.join(os.environ["pychemqt"], "dat", "moneda.dat") shutil.copy(origen, conf_dir + "moneda.dat") print( QtWidgets.QApplication.translate( "pychemqt", "Internet connection error, using archived currency rates")) # Checking database with custom components splash.showMessage( QtWidgets.QApplication.translate("pychemqt", "Checking custom database...")) if not os.path.isfile(conf_dir + "databank.db"):
filename = conf_dir+"moneda.dat" try: archivo = open(filename, "r") rates = json.load(archivo) except urllib.error.URLError: # Failed to load json file currency = True if not isinstance(rates["date"], int): # Old version exchange rates format, force upgrade currency = True if currency: # Try to retrieve exchange rates from yahoo try: firstrun.getrates(conf_dir + "moneda.dat") except (urllib.error.URLError, urllib.error.HTTPError) as e: # Internet error, get hardcoded exchanges from pychemqt distribution # Possible outdated file, try to update each some commits origen = os.path.join(os.environ["pychemqt"], "dat", "moneda.dat") shutil.copy(origen, conf_dir + "moneda.dat") print(QtWidgets.QApplication.translate("pychemqt", "Internet connection error, using archived currency rates")) # Checking database with custom components splash.showMessage(QtWidgets.QApplication.translate( "pychemqt", "Checking custom database...")) if not os.path.isfile(conf_dir + "databank.db"): firstrun.createDatabase(conf_dir + "databank.db") # Import internal libraries