def loadDataSources(ds_dir=HOME_DIR): if frozenutils.isFrozen(): if not os.path.exists(ds_dir): os.makedirs(ds_dir) frozen_path = frozenutils.frozenPath() files = glob.glob(os.path.join(frozen_path, 'sharppy', 'datasources', '*.xml')) + \ glob.glob(os.path.join(frozen_path, 'sharppy', 'datasources', '*.csv')) for file_name in files: shutil.copy(file_name, ds_dir) files = glob.glob(os.path.join(ds_dir, '*.xml')) ds = {} for ds_file in files: root = ET.parse(ds_file).getroot() for src in root: name = src.get('name') try: ds[name] = DataSource(src) except: print('Unable to process %s file'%os.path.basename(ds_file)) return ds
def loadDataSources(ds_dir=HOME_DIR): if frozenutils.isFrozen(): if not os.path.exists(ds_dir): os.makedirs(ds_dir) frozen_path = frozenutils.frozenPath() files = glob.glob(os.path.join(frozen_path, 'sharppy', 'datasources', '*.xml')) + \ glob.glob(os.path.join(frozen_path, 'sharppy', 'datasources', '*.csv')) for file_name in files: shutil.copy(file_name, ds_dir) files = glob.glob(os.path.join(ds_dir, '*.xml')) ds = {} for ds_file in files: root = ET.parse(ds_file).getroot() for src in root: name = src.get('name') try: ds[name] = DataSource(src) except: print('Unable to process %s file' % os.path.basename(ds_file)) return ds
def loadDataSources(ds_dir=HOME_DIR): """ Load the data source information from the XML files. Returns a dictionary associating data source names to DataSource objects. """ if frozenutils.isFrozen(): if not os.path.exists(ds_dir): os.makedirs(ds_dir) frozen_path = frozenutils.frozenPath() files = glob.glob(os.path.join(frozen_path, 'sharppy', 'datasources', '*.xml')) + \ glob.glob(os.path.join(frozen_path, 'sharppy', 'datasources', '*.csv')) for file_name in files: shutil.copy(file_name, ds_dir) files = glob.glob(os.path.join(ds_dir, '*.xml')) ds = {} for ds_file in files: root = ET.parse(ds_file).getroot() for src in root: name = src.get('name') try: ds[name] = DataSource(src) except Exception as e: traceback.print_exc() print("Exception: ", e) print('Unable to process %s file' % os.path.basename(ds_file)) print("This data source may not be loaded then.") return ds