当前位置: 首页>>代码示例>>Python>>正文


Python sysparam.get_string函数代码示例

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


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


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