本文整理汇总了Python中stoqlib.lib.environment.is_developer_mode函数的典型用法代码示例。如果您正苦于以下问题:Python is_developer_mode函数的具体用法?Python is_developer_mode怎么用?Python is_developer_mode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_developer_mode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: collect_traceback
def collect_traceback(tb, output=True, submit=False):
"""Collects traceback which might be submitted
@output: if it is to be printed
@submit: if it is to be submitted immediately
"""
_tracebacks.append(tb)
if output:
traceback.print_exception(*tb)
if has_raven and not is_developer_mode(): # pragma no cover
extra = collect_report()
extra.pop("tracebacks")
sentry_url = os.environ.get(
"STOQ_SENTRY_URL",
("https://89169350b0c0434895e315aa6490341a:" "[email protected]/4"),
)
client = raven.Client(sentry_url, release=stoq.version)
# Don't sent logs to sentry
if "log" in extra:
del extra["log"]
if "log_name" in extra:
del extra["log_name"]
tags = {}
for name in [
"architecture",
"cnpj",
"system",
"app_name",
"bdist_type",
"app_version",
"distribution",
"python_version",
"psycopg_version",
"pygtk_version",
"gtk_version",
"kiwi_version",
"reportlab_version",
"stoqdrivers_version",
"postgresql_version",
]:
value = extra.pop(name, None)
if value is None:
continue
tags[name] = value
client.captureException(tb, tags=tags, extra=extra)
if is_developer_mode() and submit:
rs = ReportSubmitter()
r = rs.submit()
r.get_response()
示例2: collect_traceback
def collect_traceback(tb, output=True, submit=False):
"""Collects traceback which might be submitted
@output: if it is to be printed
@submit: if it is to be submitted immediately
"""
_tracebacks.append(tb)
if output:
traceback.print_exception(*tb)
if has_raven and not is_developer_mode(): # pragma no cover
extra = collect_report()
extra.pop('tracebacks')
sentry_url = os.environ.get(
'STOQ_SENTRY_URL',
('http://89169350b0c0434895e315aa6490341a:'
'[email protected]/4'))
sentry_args = {}
if 'app_version' in sentry_args:
sentry_args['release'] = sentry_args['app_version']
client = raven.Client(sentry_url, **sentry_args)
# Don't sent logs to sentry
if 'log' in extra:
del extra['log']
if 'log_name' in extra:
del extra['log_name']
tags = {}
for name in ['architecture', 'cnpj', 'system', 'app_name', 'bdist_type',
'app_version', 'distribution', 'python_version',
'psycopg_version', 'pygtk_version', 'gtk_version',
'kiwi_version', 'reportlab_version',
'stoqdrivers_version', 'postgresql_version']:
value = extra.pop(name, None)
if value is None:
continue
if isinstance(value, (tuple, list)):
chr_ = '.' if name.endswith('_version') else ' '
value = chr_.join(str(v) for v in value)
tags[name] = value
client.captureException(tb, tags=tags, extra=extra)
if is_developer_mode() and submit:
report()
示例3: _prepare_logfiles
def _prepare_logfiles(self):
from stoqlib.lib.osutils import get_application_dir
stoqdir = get_application_dir("stoq")
log_dir = os.path.join(stoqdir, 'logs', time.strftime('%Y'),
time.strftime('%m'))
if not os.path.exists(log_dir):
os.makedirs(log_dir)
filename = 'stoq_%s.%s.log' % (time.strftime('%Y-%m-%d_%H-%M-%S'), os.getpid())
self._log_filename = os.path.join(log_dir, filename)
from kiwi.log import set_log_file
self._stream = set_log_file(self._log_filename, 'stoq*')
if platform.system() != 'Windows':
link_file = os.path.join(stoqdir, 'stoq.log')
if os.path.exists(link_file):
os.unlink(link_file)
os.symlink(self._log_filename, link_file)
# We want developers to see deprecation warnings.
from stoqlib.lib.environment import is_developer_mode
if is_developer_mode() and not self._options.quiet:
import warnings
if self._options.non_fatal_warnings:
action = "default"
else:
action = "error"
warnings.filterwarnings(
action, category=DeprecationWarning,
module="^(stoq|kiwi)")
示例4: version
def version(self, store, app_version):
"""Fetches the latest version
:param store: a store
:param app_version: application version
:returns: a deferred with the version_string as a parameter
"""
try:
bdist_type = library.bdist_type
except Exception:
bdist_type = None
if os.path.exists(os.path.join('etc', 'init.d', 'stoq-bootstrap')):
source = 'livecd'
elif bdist_type in ['egg', 'wheel']:
source = 'pypi'
elif is_developer_mode():
source = 'devel'
else:
source = 'ppa'
params = {
'hash': sysparam.get_string('USER_HASH'),
'demo': sysparam.get_bool('DEMO_MODE'),
'dist': platform.dist(),
'cnpj': get_main_cnpj(store),
'plugins': InstalledPlugin.get_plugin_names(store),
'product_key': get_product_key(),
'time': datetime.datetime.today().isoformat(),
'uname': platform.uname(),
'version': app_version,
'source': source,
}
params.update(self._get_company_details(store))
params.update(self._get_usage_stats(store))
return self._do_request('GET', 'version.json', **params)
示例5: _setup_widgets
def _setup_widgets(self):
self.set_ok_label(_(u'Activate'), gtk.STOCK_APPLY)
self.ok_button.set_sensitive(False)
plugins = []
for name in sorted(self._manager.available_plugins_names):
# FIXME: Remove when magento plugin is functional for end users
if not is_developer_mode() and name == 'magento':
continue
if platform.system() == 'Windows':
if name in ['ecf', 'tef']:
continue
desc = self._manager.get_description_by_name(name)
plugins.append(_PluginModel(name, name in
self._manager.installed_plugins_names,
desc))
self.klist = ObjectList(self._get_columns(), plugins,
gtk.SELECTION_BROWSE)
self.klist.set_headers_visible(False)
self.klist.connect("selection-changed",
self._on_klist__selection_changed)
self.main.remove(self.main.get_child())
self.main.add(self.klist)
self.klist.show()
示例6: _prepare_logfiles
def _prepare_logfiles(self):
from stoqlib.lib.osutils import get_application_dir
stoqdir = get_application_dir("stoq")
log_dir = os.path.join(stoqdir, 'logs', time.strftime('%Y'),
time.strftime('%m'))
if not os.path.exists(log_dir):
os.makedirs(log_dir)
self._log_filename = os.path.join(log_dir, 'stoq_%s.log' %
time.strftime('%Y-%m-%d_%H-%M-%S'))
from kiwi.log import set_log_file
self._stream = set_log_file(self._log_filename, 'stoq*')
if hasattr(os, 'symlink'):
link_file = os.path.join(stoqdir, 'stoq.log')
if os.path.exists(link_file):
os.unlink(link_file)
os.symlink(self._log_filename, link_file)
# We want developers to see deprecation warnings.
from stoqlib.lib.environment import is_developer_mode
if is_developer_mode():
import warnings
warnings.filterwarnings(
"default", category=DeprecationWarning,
module="^(stoq|kiwi)")
示例7: _try_show_html
def _try_show_html(self, data):
if not data:
return
if not '<html>' in data:
return
if not is_developer_mode():
return
from stoqlib.gui.widgets.webview import show_html
show_html(data)
示例8: __eq__
def __eq__(self, other):
if type(self) is not type(other):
return False
from stoqlib.lib.environment import is_developer_mode
if is_developer_mode():
# Check this only in develper mode to get as many potential errors
# as possible.
assert Store.of(self) is Store.of(other)
return self.id == other.id
示例9: _populate_serial_ports
def _populate_serial_ports(self):
values = []
for device in DeviceManager.get_serial_devices():
values.append(device.device_name)
if not self.model.device_name in values:
values.append(self.model.device_name)
if sysparam.get_bool('DEMO_MODE') or is_developer_mode():
values.append(u'/dev/null')
self.device_name.prefill(values)
示例10: _prepare_logfiles
def _prepare_logfiles(self):
from stoq.lib.logging import setup_logging
self._log_filename, self.stream = setup_logging("stoq")
from stoqlib.lib.environment import is_developer_mode
# We want developers to see deprecation warnings.
if is_developer_mode():
import warnings
warnings.filterwarnings(
"default", category=DeprecationWarning,
module="^(stoq|kiwi)")
示例11: __init__
def __init__(self, port=None):
threading.Thread.__init__(self)
self.port = port
if self.port is None and is_developer_mode():
self.port = 8080
# Indicate that this Thread is a daemon. Accordingly to the
# documentation, the entire python program exits when no alive
# non-daemon threads are left.
self.daemon = True
self.running = False
示例12: collect_traceback
def collect_traceback(tb, output=True, submit=False):
"""Collects traceback which might be submitted
@output: if it is to be printed
@submit: if it is to be submitted immediately
"""
_tracebacks.append(tb)
if output:
traceback.print_exception(*tb)
if is_developer_mode() and submit:
report()
示例13: __init__
def __init__(self, port=None):
super(Daemon, self).__init__()
self.port = port
if self.port is None and is_developer_mode():
self.port = 8080
elif self.port is None:
self.port = get_random_port()
# Indicate that this Thread is a daemon. Accordingly to the
# documentation, the entire python program exits when no alive
# non-daemon threads are left.
self.daemon = True
示例14: setup_device_port_combo
def setup_device_port_combo(self):
items = [(_("Choose..."), None)]
items.extend([(str(device.device_name), str(device.device_name))
for device in DeviceManager.get_serial_devices()])
items.extend(self._get_usb_devices())
if is_developer_mode():
# Include virtual port for virtual printer
items.append(('Virtual device', u'/dev/null'))
devices = [i[1] for i in items]
if self.model.device_name not in devices:
items.append(('Unkown device (%s)' % self.model.device_name,
self.model.device_name))
self.device_combo.prefill(items)
示例15: cmd_updateschema
def cmd_updateschema(self, options):
"""Update the database schema"""
from stoqlib.database.migration import StoqlibSchemaMigration
from stoqlib.lib.environment import is_developer_mode
self._read_config(options, check_schema=False, load_plugins=False,
register_station=False)
# This is a little bit tricky to be able to apply the initial
# plugin infrastructure
migration = StoqlibSchemaMigration()
if is_developer_mode():
backup = False
else:
backup = options.disable_backup
if not migration.update(backup=backup):
return 1