def doCrasher(*args, **kwargs): try: ret = func(*args, **kwargs) except: ret = None msg = "Well, this is embarrassing.\nSHARPpy broke. This is probably due to an issue with one of the data source servers, but if it keeps happening, send the detailed information to the developers." data = "SHARPpy v%s %s\n" % (__version__, __version_name__) + \ "Crash time: %s\n" % str(date.datetime.now()) + \ traceback.format_exc() if frozenutils.isFrozen(): msg1, msg2 = msg.split("\n") msgbox = QMessageBox() msgbox.setText(msg1) msgbox.setInformativeText(msg2) msgbox.setDetailedText(data) msgbox.setIcon(QMessageBox.Critical) msgbox.exec_() else: print print msg print print "Detailed Information:" print data if self._exit: sys.exit(1) return ret
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 doCrasher(*args, **kwargs): try: ret = func(*args, **kwargs) except Exception as e: ret = None msg = "Well, this is embarrassing.\nSHARPpy broke. This is probably due to an issue with one of the data source servers, but if it keeps happening, send the detailed information to the developers." data = "SHARPpy v%s %s\n" % (__version__, __version_name__) + \ "Crash time: %s\n" % str(date.datetime.now()) + \ traceback.format_exc() print("Exception:", e) # HERE IS WHERE YOU CAN CATCH A DATAQUALITYEXCEPTION if frozenutils.isFrozen(): msg1, msg2 = msg.split("\n") msgbox = QMessageBox() msgbox.setText(msg1) msgbox.setInformativeText(msg2) msgbox.setDetailedText(data) msgbox.setIcon(QMessageBox.Critical) msgbox.exec_() else: print() print(msg) print() print("Detailed Information:") print(data) # Check the flag that indicates if the program should exit when it crashes if self._exit: sys.exit(1) return ret
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
import xml.etree.ElementTree as ET import glob, os, sys, shutil from datetime import datetime, timedelta import urllib, urllib2 import urlparse import platform, subprocess, re import imp import sharppy.io.decoder as decoder import utils.frozenutils as frozenutils HOME_DIR = os.path.join(os.path.expanduser("~"), ".sharppy", "datasources") if frozenutils.isFrozen(): import available else: avail_loc = os.path.join(HOME_DIR, 'available.py') available = imp.load_source('available', avail_loc) # TAS: Comment this file and available.py 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'))
import sys, os import numpy as np import warnings import utils.frozenutils as frozenutils HOME_DIR = os.path.join(os.path.expanduser("~"), ".sharppy") if len(sys.argv) > 1 and sys.argv[1] == '--debug': debug = True sys.path.insert(0, os.path.normpath(os.getcwd() + "/..")) else: debug = False np.seterr(all='ignore') warnings.simplefilter('ignore') if frozenutils.isFrozen(): if not os.path.exists(HOME_DIR): os.makedirs(HOME_DIR) outfile = open(os.path.join(HOME_DIR, 'sharppy-out.txt'), 'w') sys.stdout = outfile sys.stderr = outfile from sharppy.viz.SPCWindow import SPCWindow from sharppy.viz.map import MapWidget import sharppy.sharptab.profile as profile from sharppy.io.spc_decoder import SPCDecoder from sharppy.io.buf_decoder import BufDecoder from sharppy.version import __version__, __version_name__ from datasources import data_source