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

Python sysparam.get_string函数代码示例

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

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



在下文中一共展示了get_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_get_default

 def test_get_default(self):
     location = CityLocation.get_default(self.store)
     self.failUnless(isinstance(location, CityLocation))
     self.assertEquals(location.city,
                       sysparam.get_string('CITY_SUGGESTED'))
     self.assertEquals(location.state,
                       sysparam.get_string('STATE_SUGGESTED'))
     self.assertEquals(location.country,
                       sysparam.get_string('COUNTRY_SUGGESTED'))
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:9,代码来源:test_address.py


示例2: get_default

    def get_default(cls, store):
        """Get the default city location according to the database parameters.
        The is usually the same city as main branch.

        :returns: the default city location
        """
        city = sysparam.get_string('CITY_SUGGESTED')
        state = sysparam.get_string('STATE_SUGGESTED')
        country = sysparam.get_string('COUNTRY_SUGGESTED')

        return cls.get_or_create(store, city, state, country)
开发者ID:Guillon88,项目名称:stoq,代码行数:11,代码来源:address.py


示例3: _get_parameter_value

    def _get_parameter_value(self, obj):
        """Given a ParameterData object, returns a string representation of
        its current value.
        """
        detail = sysparam.get_detail_by_name(obj.field_name)
        if detail.type == unicode:
            data = sysparam.get_string(obj.field_name)
        elif detail.type == bool:
            data = sysparam.get_bool(obj.field_name)
        elif detail.type == int:
            data = sysparam.get_int(obj.field_name)
        elif detail.type == decimal.Decimal:
            data = sysparam.get_decimal(obj.field_name)
        elif isinstance(detail.type, basestring):
            data = sysparam.get_object(self.store, obj.field_name)
        else:
            raise NotImplementedError(detail.type)

        if isinstance(data, Domain):
            if not (IDescribable in providedBy(data)):
                raise TypeError(u"Parameter `%s' must implement IDescribable "
                                "interface." % obj.field_name)
            return data.get_description()
        elif detail.options:
            return detail.options[int(obj.field_value)]
        elif isinstance(data, bool):
            return [_(u"No"), _(u"Yes")][data]
        elif obj.field_name == u'COUNTRY_SUGGESTED':
            return dgettext("iso_3166", data)
        elif isinstance(data, unicode):
            # FIXME: workaround to handle locale specific data
            return _(data)
        return unicode(data)
开发者ID:pkaislan,项目名称:stoq,代码行数:33,代码来源:parametersearch.py


示例4: save

    def save(self):
        temp_csv = tempfile.NamedTemporaryFile(suffix='.csv', delete=False, mode='w')
        writer = csv.writer(temp_csv, delimiter=',',
                            doublequote=True,
                            quoting=csv.QUOTE_ALL)
        writer.writerows(self.rows)
        temp_csv.close()

        template_file = sysparam.get_string('LABEL_TEMPLATE_PATH')
        if not os.path.exists(template_file):
            raise ValueError(_('Template file for printing labels was not found.'))

        args = ['-f', str(self.skip + 1), '-o', self.filename, '-i',
                temp_csv.name, template_file]

        # FIXME: This is just a quick workaround. There must be a better way to
        # do this.
        # glables3 changed the script name. If the default (glables2) is not
        # available, try the one from glables3
        try:
            p = Process(['glabels-batch'] + args)
        except OSError:
            p = Process(['glabels-3-batch'] + args)
        # FIXME: We should use while so the print dialog can be canceled (see
        # threadutils)
        p.wait()
开发者ID:hackedbellini,项目名称:stoq,代码行数:26,代码来源:labelreport.py


示例5: _get_instrucoes

    def _get_instrucoes(self, payment):
        instructions = []

        sale = payment.group.sale
        if sale:
            invoice_number = sale.invoice_number
        else:
            invoice_number = payment.identifier

        penalty = currency(
            (sysparam.get_decimal('BILL_PENALTY') / 100) * payment.value)
        interest = currency(
            (sysparam.get_decimal('BILL_INTEREST') / 100) * payment.value)
        discount = currency(
            (sysparam.get_decimal('BILL_DISCOUNT') / 100) * payment.value)
        data = sysparam.get_string('BILL_INSTRUCTIONS')
        for line in data.split('\n')[:4]:
            line = line.replace('$DATE', payment.due_date.strftime('%d/%m/%Y'))
            line = line.replace('$PENALTY',
                                converter.as_string(currency, penalty))
            line = line.replace('$INTEREST',
                                converter.as_string(currency, interest))
            line = line.replace('$DISCOUNT',
                                converter.as_string(currency, discount))
            line = line.replace('$INVOICE_NUMBER', str(invoice_number))
            instructions.append(line)

        instructions.append('')
        instructions.append('\n' + _('Stoq Retail Management') + ' - www.stoq.com.br')
        return instructions
开发者ID:Guillon88,项目名称:stoq,代码行数:30,代码来源:boleto.py


示例6: 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


示例7: link_update

    def link_update(self, store):
        # Setup a callback (just in case we need it)
        def callback(response=False):
            """Send data to Stoq Server if the client is using Stoq Link"""
            if not response:
                # On falsy responses we will ignore the next send data
                WebService.send_link_data = False
                return
            # On non falsy responses we will send the next data right away
            WebService.send_link_data = True
            params = {
                'hash': key,
                'data': collect_link_statistics(store)
            }
            return self._do_request('POST', 'api/lite/data', **params)

        key = sysparam.get_string('USER_HASH')
        if WebService.send_link_data is False:
            # Don't even try to send data if the user is not using Stoq Link
            return None
        elif WebService.send_link_data:
            # If the instance is using stoq link lite, we may send data
            return callback(True)

        # If we dont know if the instance is using Stoq Link, we should ask
        # our server, and then send data in case it is using it.
        params = {
            'hash': key,
            'callback': callback,
        }
        return self._do_request('GET', 'api/lite/using', **params)
开发者ID:andrebellafronte,项目名称:stoq,代码行数:31,代码来源:webservice.py


示例8: download_plugin

 def download_plugin(self, plugin_name, md5sum=None, callback=None):
     params = {
         'hash': sysparam.get_string('USER_HASH'),
         'plugin': plugin_name,
         'md5': md5sum or '',
         'version': self._get_version(),
     }
     return self._do_download_request(
         'api/eggs', callback=callback, **params)
开发者ID:zoiobnu,项目名称:stoq,代码行数:9,代码来源:webservice.py


示例9: link_registration

 def link_registration(self, name, email, phone):
     params = {
         'hash': sysparam.get_string('USER_HASH'),
         'name': name,
         'email': email,
         'phone': phone,
         'product_key': get_product_key(),
     }
     return self._do_request('POST', 'api/auth/register', **params)
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:9,代码来源:webservice.py


示例10: tef_request

 def tef_request(self, name, email, phone):
     params = {
         'hash': sysparam.get_string('USER_HASH'),
         'name': name,
         'email': email,
         'phone': phone,
         'product_key': get_product_key(),
     }
     return self._do_request('GET', 'tefrequest.json', **params)
开发者ID:andrebellafronte,项目名称:stoq,代码行数:9,代码来源:webservice.py


示例11: _get_instrucoes

    def _get_instrucoes(self, payment):
        instructions = []
        data = sysparam.get_string('BILL_INSTRUCTIONS')
        for line in data.split('\n')[:3]:
            line = line.replace('$DATE', payment.due_date.strftime('%d/%m/%Y'))
            instructions.append(line)

        instructions.append('\n' + _('Stoq Retail Management') + ' - www.stoq.com.br')
        return instructions
开发者ID:Joaldino,项目名称:stoq,代码行数:9,代码来源:boleto.py


示例12: print_labels

def print_labels(label_data, store, purchase=None):
    path = sysparam.get_string('LABEL_TEMPLATE_PATH')
    if path and os.path.exists(path):
        if purchase:
            print_report(LabelReport, purchase.get_data_for_labels(),
                         label_data.skip, store=store)
        else:
            print_report(LabelReport, [label_data], label_data.skip, store=store)
    else:
        warning(_("It was not possible to print the labels. The "
                  "template file was not found."))
开发者ID:pkaislan,项目名称:stoq,代码行数:11,代码来源:printing.py


示例13: __init__

 def __init__(self, temp, models, skip=0, store=None):
     self.store = store
     self.models = models
     self.skip = skip
     self.temp = temp
     self.rows = []
     columns = sysparam.get_string('LABEL_COLUMNS')
     columns = columns.split(',')
     for model in models:
         for i in range(int(model.quantity)):
             if not isinstance(model, Sellable):
                 model = model.sellable
             self.rows.append(_parse_row(model, columns))
开发者ID:hackedbellini,项目名称:stoq,代码行数:13,代码来源:labelreport.py


示例14: bug_report

    def bug_report(self, report):
        params = {
            'hash': sysparam.get_string('USER_HASH'),
            'product_key': get_product_key(),
            'report': json.dumps(report)
        }
        if os.environ.get('STOQ_DISABLE_CRASHREPORT'):
            d = Deferred()
            sys.stderr.write(report)
            d.callback({'report-url': '<not submitted>',
                        'report': '<none>'})
            return d

        return self._do_request('POST', 'v2/bugreport.json', **params)
开发者ID:andrebellafronte,项目名称:stoq,代码行数:14,代码来源:webservice.py


示例15: get_l10n_module

def get_l10n_module(country=None):
    if not country:
        from stoqlib.lib.parameters import sysparam
        country = sysparam.get_string('COUNTRY_SUGGESTED')

    short = iso639_list.get(country.lower(), None)
    if short is None:
        return generic

    path = 'stoqlib.l10n.%s.%s' % (short, short)
    try:
        module = namedAny(path)
    except (ImportError, AttributeError):
        return generic

    return module
开发者ID:Guillon88,项目名称:stoq,代码行数:16,代码来源:l10n.py


示例16: feedback

 def feedback(self, screen, email, feedback):
     default_store = get_default_store()
     params = {
         'hash': sysparam.get_string('USER_HASH'),
         'cnpj': get_main_cnpj(default_store),
         'demo': sysparam.get_bool('DEMO_MODE'),
         'dist': ' '.join(platform.dist()),
         'email': email,
         'feedback': feedback,
         'plugins': ', '.join(InstalledPlugin.get_plugin_names(default_store)),
         'product_key': get_product_key(),
         'screen': screen,
         'time': datetime.datetime.today().isoformat(),
         'uname': ' '.join(platform.uname()),
         'version': self._get_version(),
     }
     return self._do_request('GET', 'feedback.json', **params)
开发者ID:amaurihamasu,项目名称:stoq,代码行数:17,代码来源:webservice.py


示例17: 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
     """
     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,
     }
     return self._do_request('GET', 'version.json', **params)
开发者ID:andrebellafronte,项目名称:stoq,代码行数:18,代码来源:webservice.py


示例18: sysparam

 def sysparam(self, **kwargs):
     """
     Updates a set of system parameters within a context.
     The values will be reverted when leaving the scope.
     kwargs contains a dictionary of parameter name->value
     """
     from stoqlib.lib.parameters import sysparam
     old_values = {}
     for param, value in kwargs.items():
         if isinstance(value, bool):
             old_values[param] = sysparam.get_bool(param)
             sysparam.set_bool(self.store, param, value)
         elif isinstance(value, int):
             old_values[param] = sysparam.get_int(param)
             sysparam.set_int(self.store, param, value)
         elif isinstance(value, Domain) or value is None:
             old_values[param] = sysparam.get_object(self.store, param)
             sysparam.set_object(self.store, param, value)
         elif isinstance(value, str):
             old_values[param] = sysparam.get_string(param)
             sysparam.set_string(self.store, param, value)
         elif isinstance(value, Decimal):
             old_values[param] = sysparam.get_decimal(param)
             sysparam.set_decimal(self.store, param, value)
         else:
             raise NotImplementedError(type(value))
     try:
         yield
     finally:
         for param, value in old_values.items():
             if isinstance(value, bool):
                 sysparam.set_bool(self.store, param, value)
             elif isinstance(value, int):
                 sysparam.set_int(self.store, param, value)
             elif isinstance(value, Domain) or value is None:
                 sysparam.set_object(self.store, param, value)
             elif isinstance(value, str):
                 sysparam.set_string(self.store, param, value)
             elif isinstance(value, Decimal):
                 sysparam.set_decimal(self.store, param, value)
             else:
                 raise NotImplementedError(type(value))
开发者ID:hackedbellini,项目名称:stoq,代码行数:42,代码来源:domaintest.py


示例19: download_plugin

    def download_plugin(self, plugin_name, md5sum=None, callback=None):
        params = {
            'hash': sysparam.get_string('USER_HASH'),
            'plugin': plugin_name,
            'md5': md5sum or '',
            'version': self._get_version(),
        }

        def errback(code, error):
            if code == '204':
                log.info("No update needed. The plugin is already up to date.")
            else:
                return_messages = {
                    '400': "Plugin not available for this stoq version",
                    '404': "Plugin does not exist",
                    '405': "This instance has not acquired the specified plugin",
                }
                log.warning(return_messages.get(code, str(error)))

        return self._do_download_request(
            'api/eggs', callback=callback, errback=errback, **params)
开发者ID:amaurihamasu,项目名称:stoq,代码行数:21,代码来源:webservice.py


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sysparam.set_bool函数代码示例发布时间:2022-05-27
下一篇:
Python sysparam.get_object_id函数代码示例发布时间: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