Esempio n. 1
0
def marker(msg):
    if os.environ.get('STOQ_DEBUG'):
        sys.stderr.write('[%.3f] %s\n' % (
            get_uptime(),
            msg,
        ))
Esempio n. 2
0
def collect_report():
    report = {}

    # Date and uptime
    report['date'] = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    report['tz'] = time.tzname
    report['uptime'] = get_uptime()
    report['locale'] = get_system_locale()

    # Python and System
    import platform
    report['architecture'] = platform.architecture()
    report['distribution'] = platform.dist()
    report['python_version'] = tuple(sys.version_info)
    report['system'] = platform.system()
    report['uname'] = platform.uname()

    # Stoq application
    info = get_utility(IAppInfo, None)
    if info and info.get('name'):
        report['app_name'] = info.get('name')
        report['app_version'] = info.get('ver')

    # External dependencies
    import gtk
    report['pygtk_version'] = gtk.pygtk_version
    report['gtk_version'] = gtk.gtk_version

    import kiwi
    report['kiwi_version'] = kiwi.__version__.version + (_get_revision(kiwi), )

    import psycopg2
    try:
        parts = psycopg2.__version__.split(' ')
        extra = ' '.join(parts[1:])
        report['psycopg_version'] = tuple(map(int,
                                              parts[0].split('.'))) + (extra, )
    except:
        report['psycopg_version'] = psycopg2.__version__

    import reportlab
    report['reportlab_version'] = reportlab.Version.split('.')

    import stoqdrivers
    report['stoqdrivers_version'] = stoqdrivers.__version__ + (
        _get_revision(stoqdrivers), )

    # PostgreSQL database server
    try:
        default_store = get_default_store()
        result = default_store.execute('SHOW server_version;')
        pg_version = result.get_one()
        result.close()
        report['postgresql_version'] = list(map(int, pg_version[0].split('.')))
    except StoqlibError:
        pass

    # Tracebacks
    report['tracebacks'] = {}
    for i, trace in enumerate(_tracebacks):
        t = ''.join(traceback.format_exception(*trace))
        # Eliminate duplicates:
        md5sum = hashlib.md5(t).hexdigest()
        report['tracebacks'][md5sum] = t

    if info and info.get('log'):
        report['log'] = open(info.get('log')).read()
        report['log_name'] = info.get('log')

    return report
Esempio n. 3
0
def marker(msg):
    if os.environ.get('STOQ_DEBUG'):
        print >> sys.stderr, '[%.3f] %s' % (get_uptime(), msg, )
Esempio n. 4
0
def collect_report():
    report_ = {}

    # Date and uptime
    report_["date"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    report_["tz"] = time.tzname
    report_["uptime"] = get_uptime()
    report_["locale"] = get_system_locale()

    # Python and System
    import platform

    report_["architecture"] = " ".join(platform.architecture())
    report_["distribution"] = " ".join(platform.dist())
    report_["python_version"] = _fix_version(sys.version_info)
    report_["uname"] = " ".join(platform.uname())
    report_["system"] = platform.system()

    # Stoq application
    info = get_utility(IAppInfo, None)
    if info and info.get("name"):
        report_["app_name"] = info.get("name")
        report_["app_version"] = _fix_version(info.get("ver"))

    # External dependencies
    import gtk

    report_["pygtk_version"] = _fix_version(gtk.pygtk_version)
    report_["gtk_version"] = _fix_version(gtk.gtk_version)

    import kiwi

    report_["kiwi_version"] = _fix_version(kiwi.__version__.version + (_get_revision(kiwi),))

    import psycopg2

    try:
        parts = psycopg2.__version__.split(" ")
        extra = " ".join(parts[1:])
        report_["psycopg_version"] = _fix_version(map(int, parts[0].split(".")) + [extra])
    except:
        report_["psycopg_version"] = _fix_version(psycopg2.__version__)

    import reportlab

    report_["reportlab_version"] = _fix_version(reportlab.Version)

    import stoqdrivers

    report_["stoqdrivers_version"] = _fix_version(stoqdrivers.__version__ + (_get_revision(stoqdrivers),))

    report_["product_key"] = get_product_key()

    try:
        from stoqlib.lib.kiwilibrary import library

        report_["bdist_type"] = library.bdist_type
    except Exception:
        pass

    # PostgreSQL database server
    try:
        from stoqlib.database.settings import get_database_version

        default_store = get_default_store()
        report_["postgresql_version"] = _fix_version(get_database_version(default_store))
        report_["demo"] = sysparam.get_bool("DEMO_MODE")
        report_["cnpj"] = get_main_cnpj(default_store)
        report_["plugins"] = ", ".join(InstalledPlugin.get_plugin_names(default_store))
    except Exception:
        pass

    # Tracebacks
    report_["tracebacks"] = {}
    for i, trace in enumerate(_tracebacks):
        t = "".join(traceback.format_exception(*trace))
        # Eliminate duplicates:
        md5sum = hashlib.md5(t).hexdigest()
        report_["tracebacks"][md5sum] = t

    if info and info.get("log"):
        report_["log"] = open(info.get("log")).read()
        report_["log_name"] = info.get("log")

    return report_
Esempio n. 5
0
def collect_report():
    report_ = {}

    # Date and uptime
    report_['date'] = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    report_['tz'] = time.tzname
    report_['uptime'] = get_uptime()
    report_['locale'] = get_system_locale()

    # Python and System
    import platform
    report_['architecture'] = platform.architecture()
    report_['distribution'] = platform.dist()
    report_['python_version'] = tuple(sys.version_info)
    report_['system'] = platform.system()
    report_['uname'] = platform.uname()

    # Stoq application
    info = get_utility(IAppInfo, None)
    if info and info.get('name'):
        report_['app_name'] = info.get('name')
        report_['app_version'] = info.get('ver')

    # External dependencies
    import gtk
    report_['pygtk_version'] = gtk.pygtk_version
    report_['gtk_version'] = gtk.gtk_version

    import kiwi
    report_['kiwi_version'] = kiwi.__version__.version + (_get_revision(kiwi),)

    import psycopg2
    try:
        parts = psycopg2.__version__.split(' ')
        extra = ' '.join(parts[1:])
        report_['psycopg_version'] = tuple(map(int, parts[0].split('.'))) + (extra,)
    except:
        report_['psycopg_version'] = psycopg2.__version__

    import reportlab
    report_['reportlab_version'] = reportlab.Version.split('.')

    import stoqdrivers
    report_['stoqdrivers_version'] = stoqdrivers.__version__ + (
        _get_revision(stoqdrivers),)

    report_['product_key'] = get_product_key()

    try:
        from stoqlib.lib.kiwilibrary import library
        report_['bdist_type'] = library.bdist_type
    except Exception:
        pass

    # PostgreSQL database server
    try:
        from stoqlib.database.settings import get_database_version
        default_store = get_default_store()
        report_['postgresql_version'] = get_database_version(default_store)
        report_['plugins'] = InstalledPlugin.get_plugin_names(default_store)
        report_['demo'] = sysparam.get_bool('DEMO_MODE')
        report_['cnpj'] = get_main_cnpj(default_store)
    except Exception:
        pass

    # Tracebacks
    report_['tracebacks'] = {}
    for i, trace in enumerate(_tracebacks):
        t = ''.join(traceback.format_exception(*trace))
        # Eliminate duplicates:
        md5sum = hashlib.md5(t).hexdigest()
        report_['tracebacks'][md5sum] = t

    if info and info.get('log'):
        report_['log'] = open(info.get('log')).read()
        report_['log_name'] = info.get('log')

    return report_
Esempio n. 6
0
def collect_report():
    report_ = {}

    # Date and uptime
    report_['date'] = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    report_['tz'] = time.tzname
    report_['uptime'] = get_uptime()
    report_['locale'] = get_system_locale()

    # Python and System
    import platform
    report_['architecture'] = ' '.join(platform.architecture())
    report_['distribution'] = ' '.join(platform.dist())
    report_['python_version'] = _fix_version(sys.version_info)
    report_['uname'] = ' '.join(platform.uname())
    report_['system'] = platform.system()

    # Stoq application
    info = get_utility(IAppInfo, None)
    if info and info.get('name'):
        report_['app_name'] = info.get('name')
        report_['app_version'] = _fix_version(info.get('ver'))

    # External dependencies
    import gi
    report_['gtk_version'] = _fix_version(gi.version_info)

    import kiwi
    report_['kiwi_version'] = _fix_version(
        kiwi.__version__.version + (_get_revision(kiwi), ))

    import psycopg2
    try:
        parts = psycopg2.__version__.split(' ')
        extra = ' '.join(parts[1:])
        report_['psycopg_version'] = _fix_version(
            list(map(int, parts[0].split('.'))) + [extra])
    except Exception:
        report_['psycopg_version'] = _fix_version(psycopg2.__version__)

    import reportlab
    report_['reportlab_version'] = _fix_version(reportlab.Version)

    import stoqdrivers
    report_['stoqdrivers_version'] = _fix_version(
        stoqdrivers.__version__ + (_get_revision(stoqdrivers), ))

    report_['product_key'] = get_product_key()

    try:
        from stoqlib.lib.kiwilibrary import library
        report_['bdist_type'] = library.bdist_type
    except Exception:
        pass

    # PostgreSQL database server
    try:
        from stoqlib.database.settings import get_database_version
        default_store = get_default_store()
        report_['postgresql_version'] = _fix_version(
            get_database_version(default_store))
        report_['demo'] = sysparam.get_bool('DEMO_MODE')
        report_['hash'] = sysparam.get_string('USER_HASH')
        report_['cnpj'] = get_main_cnpj(default_store)
        report_['plugins'] = ', '.join(
            InstalledPlugin.get_plugin_names(default_store))
    except Exception:
        pass

    # Tracebacks
    report_['tracebacks'] = {}
    for i, trace in enumerate(_tracebacks):
        t = ''.join(traceback.format_exception(*trace))
        # Eliminate duplicates:
        md5sum = hashlib.md5(t).hexdigest()
        report_['tracebacks'][md5sum] = t

    if info and info.get('log'):
        report_['log'] = open(info.get('log')).read()
        report_['log_name'] = info.get('log')

    return report_
Esempio n. 7
0
def collect_report():
    report_ = {}

    # Date and uptime
    report_["date"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    report_["tz"] = time.tzname
    report_["uptime"] = get_uptime()
    report_["locale"] = get_system_locale()

    # Python and System
    import platform

    report_["architecture"] = platform.architecture()
    report_["distribution"] = platform.dist()
    report_["python_version"] = tuple(sys.version_info)
    report_["system"] = platform.system()
    report_["uname"] = platform.uname()

    # Stoq application
    info = get_utility(IAppInfo, None)
    if info and info.get("name"):
        report_["app_name"] = info.get("name")
        report_["app_version"] = info.get("ver")

    # External dependencies
    import gtk

    report_["pygtk_version"] = gtk.pygtk_version
    report_["gtk_version"] = gtk.gtk_version

    import kiwi

    report_["kiwi_version"] = kiwi.__version__.version + (_get_revision(kiwi),)

    import psycopg2

    try:
        parts = psycopg2.__version__.split(" ")
        extra = " ".join(parts[1:])
        report_["psycopg_version"] = tuple(map(int, parts[0].split("."))) + (extra,)
    except:
        report_["psycopg_version"] = psycopg2.__version__

    import reportlab

    report_["reportlab_version"] = reportlab.Version.split(".")

    import stoqdrivers

    report_["stoqdrivers_version"] = stoqdrivers.__version__ + (_get_revision(stoqdrivers),)

    # PostgreSQL database server
    try:
        default_store = get_default_store()
        result = default_store.execute("SHOW server_version;")
        pg_version = result.get_one()
        result.close()
        report_["postgresql_version"] = list(map(int, pg_version[0].split(".")))
    except StoqlibError:
        pass

    # Tracebacks
    report_["tracebacks"] = {}
    for i, trace in enumerate(_tracebacks):
        t = "".join(traceback.format_exception(*trace))
        # Eliminate duplicates:
        md5sum = hashlib.md5(t).hexdigest()
        report_["tracebacks"][md5sum] = t

    if info and info.get("log"):
        report_["log"] = open(info.get("log")).read()
        report_["log_name"] = info.get("log")

    return report_
Esempio n. 8
0
def collect_report():
    report_ = {}

    # Date and uptime
    report_['date'] = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    report_['tz'] = time.tzname
    report_['uptime'] = get_uptime()
    report_['locale'] = get_system_locale()

    # Python and System
    import platform
    report_['architecture'] = platform.architecture()
    report_['distribution'] = platform.dist()
    report_['python_version'] = tuple(sys.version_info)
    report_['system'] = platform.system()
    report_['uname'] = platform.uname()

    # Stoq application
    info = get_utility(IAppInfo, None)
    if info and info.get('name'):
        report_['app_name'] = info.get('name')
        report_['app_version'] = info.get('ver')

    # External dependencies
    import gtk
    report_['pygtk_version'] = gtk.pygtk_version
    report_['gtk_version'] = gtk.gtk_version

    import kiwi
    report_['kiwi_version'] = kiwi.__version__.version + (_get_revision(kiwi),)

    import psycopg2
    try:
        parts = psycopg2.__version__.split(' ')
        extra = ' '.join(parts[1:])
        report_['psycopg_version'] = tuple(map(int, parts[0].split('.'))) + (extra,)
    except:
        report_['psycopg_version'] = psycopg2.__version__

    import reportlab
    report_['reportlab_version'] = reportlab.Version.split('.')

    import stoqdrivers
    report_['stoqdrivers_version'] = stoqdrivers.__version__ + (
        _get_revision(stoqdrivers),)

    # PostgreSQL database server
    try:
        default_store = get_default_store()
        result = default_store.execute('SHOW server_version;')
        pg_version = result.get_one()
        result.close()
        report_['postgresql_version'] = list(map(int, pg_version[0].split('.')))
    except StoqlibError:
        pass

    # Tracebacks
    report_['tracebacks'] = {}
    for i, trace in enumerate(_tracebacks):
        t = ''.join(traceback.format_exception(*trace))
        # Eliminate duplicates:
        md5sum = hashlib.md5(t).hexdigest()
        report_['tracebacks'][md5sum] = t

    if info and info.get('log'):
        report_['log'] = open(info.get('log')).read()
        report_['log_name'] = info.get('log')

    return report_
Esempio n. 9
0
def marker(msg):
    if os.environ.get('STOQ_DEBUG'):
        sys.stderr.write('[%.3f] %s\n' % (get_uptime(), msg, ))