• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python environment.is_developer_mode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stoqlib.lib.environment.is_developer_mode函数的典型用法代码示例。如果您正苦于以下问题:Python is_developer_mode函数的具体用法?Python is_developer_mode怎么用?Python is_developer_mode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了is_developer_mode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:stoq,项目名称:stoq,代码行数:55,代码来源:crashreport.py


示例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()
开发者ID:Guillon88,项目名称:stoq,代码行数:48,代码来源:crashreport.py


示例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)")
开发者ID:hackedbellini,项目名称:stoq,代码行数:32,代码来源:bootstrap.py


示例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)
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:35,代码来源:webservice.py


示例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()
开发者ID:romaia,项目名称:stoq,代码行数:26,代码来源:pluginsdialog.py


示例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)")
开发者ID:LeonamSilva,项目名称:stoq,代码行数:28,代码来源:bootstrap.py


示例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)
开发者ID:andrebellafronte,项目名称:stoq,代码行数:10,代码来源:webservice.py


示例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
开发者ID:hackedbellini,项目名称:stoq,代码行数:10,代码来源:orm.py


示例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)
开发者ID:hackedbellini,项目名称:stoq,代码行数:10,代码来源:ecfprinterdialog.py


示例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)")
开发者ID:romaia,项目名称:stoq,代码行数:11,代码来源:bootstrap.py


示例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
开发者ID:Guillon88,项目名称:stoq,代码行数:11,代码来源:daemonutils.py


示例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()
开发者ID:rosalin,项目名称:stoq,代码行数:12,代码来源:crashreport.py


示例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
开发者ID:hackedbellini,项目名称:stoq,代码行数:12,代码来源:daemonutils.py


示例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)
开发者ID:hackedbellini,项目名称:stoq,代码行数:15,代码来源:deviceseditor.py


示例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
开发者ID:barkinet,项目名称:stoq,代码行数:19,代码来源:dbadmin.py


示例16: _setup_gtk

    def _setup_gtk(self):
        from gi.repository import Gtk, Gdk
        from kiwi.environ import environ
        from stoqlib.lib.template import render_template_string

        # Total madness to make sure we can draw treeview lines,
        # this affects the GtkTreeView::grid-line-pattern style property
        #
        # Two bytes are sent in, see gtk_tree_view_set_grid_lines in gtktreeview.c
        # Byte 1 should be as high as possible, gtk+ 0x7F appears to be
        #        the highest allowed for Gtk+ 2.22 while 0xFF worked in
        #        earlier versions
        # Byte 2 should ideally be allowed to be 0, but neither C nor Python
        #        allows that.
        #
        data = environ.get_resource_string("stoq", "misc", "stoq.css")
        data = render_template_string(data)

        style_provider = Gtk.CssProvider()
        style_provider.load_from_data(data)
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(),
            style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        settings = Gtk.Settings.get_default()
        settings.props.gtk_button_images = True

        from stoqlib.lib.environment import is_developer_mode
        if is_developer_mode():
            # Install a Control-Q handler that forcefully exits
            # the program without saving any kind of state
            def event_handler(event):
                state = event.get_state()
                if isinstance(state, tuple):
                    state = state[1]
                if (event.type == Gdk.EventType.KEY_PRESS and
                        state & Gdk.ModifierType.CONTROL_MASK and
                        event.keyval == Gdk.KEY_q):
                    os._exit(0)
                Gtk.main_do_event(event)
            Gdk.event_handler_set(event_handler)
开发者ID:hackedbellini,项目名称:stoq,代码行数:42,代码来源:bootstrap.py


示例17: version

    def version(self, store, app_version, **kwargs):
        """Fetches the latest version

        :param store: a store
        :param app_version: application version
        """
        import stoq
        try:
            bdist_type = library.bdist_type
        except Exception:
            bdist_type = None

        # We should use absolute paths when looking for /etc
        if os.path.exists(os.path.join(os.sep, 'etc', 'init.d', 'stoq-bootstrap')):
            source = 'livecd'
        elif stoq.trial_mode:
            source = 'trial'
        elif bdist_type in ['egg', 'wheel']:
            source = 'pypi'
        elif is_developer_mode():
            source = 'devel'
        else:
            source = 'ppa'

        params = {
            'demo': sysparam.get_bool('DEMO_MODE'),
            'dist': ' '.join(platform.dist()),
            'cnpj': get_main_cnpj(store),
            'plugins': ' '.join(InstalledPlugin.get_plugin_names(store)),
            'product_key': get_product_key(),
            'uname': ' '.join(platform.uname()),
            'version': app_version,
            'source': source,
        }
        params.update(self._get_company_details(store))
        params.update(self._get_usage_stats(store))

        endpoint = 'api/stoq/v1/version/%s' % (sysparam.get_string('USER_HASH'), )
        return self._do_request('POST', endpoint, json=params, **kwargs)
开发者ID:hackedbellini,项目名称:stoq,代码行数:39,代码来源:webservice.py


示例18: _setup_gtk

    def _setup_gtk(self):
        import gtk
        from kiwi.environ import environ

        gtk.gdk.threads_init()
        # Total madness to make sure we can draw treeview lines,
        # this affects the GtkTreeView::grid-line-pattern style property
        #
        # Two bytes are sent in, see gtk_tree_view_set_grid_lines in gtktreeview.c
        # Byte 1 should be as high as possible, gtk+ 0x7F appears to be
        #        the highest allowed for Gtk+ 2.22 while 0xFF worked in
        #        earlier versions
        # Byte 2 should ideally be allowed to be 0, but neither C nor Python
        #        allows that.
        #
        data = environ.get_resource_string("stoq", "misc", "stoq.gtkrc")
        data = data.replace('\\x7f\\x01', '\x7f\x01')

        gtk.rc_parse_string(data)

        # Creating a button as a temporary workaround for bug
        # https://bugzilla.gnome.org/show_bug.cgi?id=632538, until gtk 3.0
        gtk.Button()
        settings = gtk.settings_get_default()
        settings.props.gtk_button_images = True

        from stoqlib.lib.environment import is_developer_mode
        if is_developer_mode() and gtk.gtk_version[0] == 2:
            from gtk import gdk

            # Install a Control-Q handler that forcefully exits
            # the program without saving any kind of state
            def event_handler(event):
                if (event.type == gdk.KEY_PRESS and
                    event.state & gdk.CONTROL_MASK and
                    event.keyval == gtk.keysyms.q):
                    os._exit(0)
                gtk.main_do_event(event)
            gdk.event_handler_set(event_handler)
开发者ID:pkaislan,项目名称:stoq,代码行数:39,代码来源:bootstrap.py


示例19: 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 "STOQ_SENTRY_URL" in os.environ:
        try:
            from raven import Client

            has_raven = True
        except ImportError:
            has_raven = False

        if has_raven:
            client = Client(os.environ["STOQ_SENTRY_URL"])
            client.captureException(tb)

    if is_developer_mode() and submit:
        report()
开发者ID:pkaislan,项目名称:stoq,代码行数:23,代码来源:crashreport.py


示例20: is_developer_mode

 def is_developer_mode(self):
     return is_developer_mode()
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:2,代码来源:api.py



注:本文中的stoqlib.lib.environment.is_developer_mode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python formatters.format_quantity函数代码示例发布时间:2022-05-27
下一篇:
Python defaults.quantize函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap