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


Python ConfigParser.get_configparser方法代码示例

本文整理汇总了Python中kivy.config.ConfigParser.get_configparser方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.get_configparser方法的具体用法?Python ConfigParser.get_configparser怎么用?Python ConfigParser.get_configparser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.config.ConfigParser的用法示例。


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

示例1: load_config

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
    def load_config(self):
        '''(internal) This function is used for returning a ConfigParser with
        the application configuration. It's doing 3 things:

            #. Creating an instance of a ConfigParser
            #. Loading the default configuration by calling
               :meth:`build_config`, then
            #. If it exists, it loads the application configuration file,
               otherwise it creates one.

        :return:
            :class:`~kivy.config.ConfigParser` instance
        '''
        try:
            config = ConfigParser.get_configparser('app')
        except KeyError:
            config = None
        if config is None:
            config = ConfigParser(name='app')
        self.config = config
        self.build_config(config)
        # if no sections are created, that's mean the user don't have
        # configuration.
        if len(config.sections()) == 0:
            return
        # ok, the user have some sections, read the default file if exist
        # or write it !
        filename = self.get_application_config()
        if filename is None:
            return config
        Logger.debug('App: Loading configuration <{0}>'.format(filename))
        if exists(filename):
            try:
                config.read(filename)
            except:
                Logger.error('App: Corrupted config file, ignored.')
                config.name = ''
                try:
                    config = ConfigParser.get_configparser('app')
                except KeyError:
                    config = None
                if config is None:
                    config = ConfigParser(name='app')
                self.config = config
                self.build_config(config)
                pass
        else:
            Logger.debug('App: First configuration, create <{0}>'.format(
                filename))
            config.filename = filename
            config.write()
        return config
开发者ID:AndiEcker,项目名称:kivy,代码行数:54,代码来源:app.py

示例2: do_search

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
    def do_search(self):
        def on_success(req, result):
            print ('search success.')
            for p in result['result']:
                p_id = str(p['id'])
                if p['code'] is None or p['code'] == '':
                    subtext = p['name']
                else:
                    subtext = p['code']
                image_source = self.get_local_image(p)
                btn = Factory.CustomButton(image_source=image_source, id=p_id,
                                           size_hint_y=None, width=300, height=100, subtext=subtext)
                btn.bind(on_press=self.do_add_item)
                self.products_search_list.append(btn)
                self.my_tabbed_panel_wid.grid_layout_search_wid.add_widget(btn)
                self.my_tabbed_panel_wid.switch_to(self.my_tabbed_panel_wid.tab_search_wid)
            self.my_tabbed_panel_wid.grid_layout_search_wid.height = (len(result['result'])/4+4)*110
            self.text_input_wid.text = ''

        def on_failure(req, result):
            on_error(req, result)

        def on_error(req, result):
            print ('POSScrean.search().on_error() ')

        print ('POSScreen.do_search():')
        if len(self.products_search_list) > 0:
            for n in self.products_search_list:
                self.my_tabbed_panel_wid.grid_layout_search_wid.remove_widget(n)
        self.products_search_list = []
        config = ConfigParser.get_configparser(name='app')
        producturl = config.get('serverconnection', 'server.url') + "pos/product/" + self.text_input_wid.text
        UrlRequest(producturl, on_success=on_success, on_failure=on_failure, on_error=on_error)
开发者ID:jerome76,项目名称:web-prototype,代码行数:35,代码来源:POSScreen.py

示例3: load_all_images

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
 def load_all_images(self):
     config = ConfigParser.get_configparser(name='app')
     for p in self.products_json['result']:
         image_name = p['code']
         if p['code'] is None:
             image_name = str(p['id'])
         image_file = image_name + "-small.png"
         self.download_photo(config.get('serverconnection', 'server.url') + "static/products/" + image_file,
                             "./products/" + image_file)
开发者ID:jerome76,项目名称:web-prototype,代码行数:11,代码来源:POSScreen.py

示例4: pay

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
    def pay(self):
        unique_id = uuid.uuid4()

        def on_success(req, result):
            os.remove('offline/' + str(unique_id) + '.json')
            self.manager.get_screen('posscreen').icon_wid.source = 'icon.png'
            with open('sale.json', 'w') as fp:
                json.dump(result, fp)
                fp.close()
            self.sale_json = result
            print ('on_success: sale returned.')
            self.manager.get_screen('posscreen').do_clear_item_list()
            self.parent.current = "posscreen"

        def on_failure(req, result):
            on_error(req, result)

        def on_error(req, result):
            print ('on_error: Could not send payment. Save to file instead.')
            self.manager.get_screen('posscreen').icon_wid.source = 'icon_offline.png'
            self.manager.get_screen('posscreen').do_clear_item_list()
            self.parent.current = "posscreen"

        try:
            print("Pay and clear list")
            payslip_json = dict([])
            payslip_positions = self.manager.get_screen('posscreen').my_data_view
            customer = dict([])
            customer['customerid'] = self.manager.get_screen('posscreen').customer_id
            payslip_json['customer'] = customer
            payslip_items = []
            for i in payslip_positions:
                print("selling: " + str(i))
                next_element = self.getProduct(i.product_code)
                if next_element is not None:
                    payslip_items.append(next_element)
            payslip_json['items'] = payslip_items
            with open('offline/' + str(unique_id) + '.json', 'w') as fp:
                json.dump(payslip_json, fp)
                fp.close()
            # clear list
            config = ConfigParser.get_configparser(name='app')
            print(config.get('serverconnection', 'server.url'))
            saleurl = config.get('serverconnection', 'server.url') + "pos/sale/"
            data_json = json.dumps(payslip_json)
            headers = {'Content-type': 'application/jsonrequest', 'Accept': 'application/jsonrequest'}
            if len(self.manager.get_screen('posscreen').my_data_view) > 0:
                UrlRequest(url=saleurl, on_success=on_success, on_failure=on_failure, on_error=on_error, req_headers=headers, req_body=data_json)
            else:
                self.manager.get_screen('posscreen').do_clear_item_list()
                self.parent.current = "posscreen"
        except Exception:
            print(traceback.format_exc())
            print "PaymentScreen.pay() Error: Could not send payslip"
开发者ID:togobananas-semilimes,项目名称:milliondog_website,代码行数:56,代码来源:PaymentScreen.py

示例5: on_pre_enter

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
    def on_pre_enter(self, *args):
        def on_success(req, result):
            self.icon_wid.source = 'icon.png'
            with open('products.json', 'w') as fp:
                json.dump(result, fp)
                fp.close()
            self.products_json = result
            print ('products loaded.')

            if len(result['result']) > 0:
                self.grid_layout_home_wid.clear_widgets()
            for i in result['result']:
                code = i['code']
                if code == '':
                    code = '200001'
                btn = Factory.CustomButton(image_source='./products/'+code+'-small.png', id=code,
                                           size_hint_y=None, width=300, height=100, subtext=code)
                btn.bind(on_press=self.do_add_item)
                self.products_list.append(btn)
                print ('add online product ' + code)
                self.grid_layout_home_wid.add_widget(btn)
            self.grid_layout_home_wid.height = (len(result['result'])/4)*110
        try:
            config = ConfigParser.get_configparser(name='app')
            print(config.get('serverconnection', 'server.url'))
            producturl = config.get('serverconnection', 'server.url') + "pos/products/"
            if len(self.products_list) == 0:
                UrlRequest(producturl, on_success)
            else:
                return
        except:
            print "POSScreen Error: Could not load products"
        print "Initialize products selection"
        for key, val in self.ids.items():
            print("key={0}, val={1}".format(key, val))
        if len(self.products_list) > 0:
            for n in self.products_list:
                self.grid_layout_home_wid.remove_widget(n)
        if len(self.products_list) == 0:
            with open('products.json') as data_file:
                result = json.load(data_file)
                self.products_json = result
            for i in result['result']:
                code = i['code']
                if code == '':
                    code = '200001'
                btn = Factory.CustomButton(image_source='./products/'+code+'-small.png', id=code,
                                           size_hint_y=None, width=300, height=100, subtext=code)
                btn.bind(on_press=self.do_add_item)
                self.products_list.append(btn)
                print ('add local product ' + code)
                self.grid_layout_home_wid.add_widget(btn)
            self.grid_layout_home_wid.height = (len(result['result'])/4)*110
开发者ID:togobananas-semilimes,项目名称:milliondog_website,代码行数:55,代码来源:POSScreen.py

示例6: on_release

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
 def on_release(self):
     print ('POSScreen.ImageButton.on_press: upload payslips')
     upload_count = len(glob.glob('offline/*.json'))
     if upload_count > 0:
         self.popup.open()
         self.pb.value = 0
         file_count = len(glob.glob('offline/*.json'))
         increment = 100.0/file_count + 1
         for fn in glob.glob('offline/*.json'):
             if os.path.isfile(fn):
                 Clock.schedule_once(partial(self.upload_payslips, fn, increment), 0)
     config = ConfigParser.get_configparser(name='app')
     if config.get('section1', 'download_images_after_sync') == 'True':
         self.parent.parent.parent.load_all_images()
开发者ID:jerome76,项目名称:web-prototype,代码行数:16,代码来源:POSScreen.py

示例7: build

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
 def build(self):
     config = ConfigParser.get_configparser(name='app')
     producturl = config.get('serverconnection', 'server.url') + "pos/product/" + '200018'
     data = json.load(urllib2.urlopen(producturl))
     product = data['result'][0]
     layout = BoxLayout(orientation='vertical')
     # use a (r, g, b, a) tuple
     blue = (0, 0, 1.5, 2.5)
     red = (2.5, 0, 0, 1.5)
     btn = Button(text='Touch me!'+product['name'], background_color=blue, font_size=40)
     btn.bind(on_press=self.callback)
     self.label = Label(text="------------", font_size='50sp')
     layout.add_widget(btn)
     layout.add_widget(self.label)
     return layout
开发者ID:togobananas-semilimes,项目名称:milliondog_website,代码行数:17,代码来源:POSScreen.py

示例8: post_init

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
 def post_init(self, *args):
     config = ConfigParser.get_configparser(name='app')
     self.customer_id = config.get('section1', 'default_customer_id')
     self.order_id = int(config.get('section1', 'default_order_id'))
     with open('customers.json') as data_file:
         result = json.load(data_file)
         self.customers_json = result
     for c in result['result']:
         self.customers_list.append(c)
     customer = self.get_customer(self.customer_id)
     if customer:
         self.customer_name = customer["name"]
     else:
         self.customer_name = '???'
     self.btn_customer_wid.text = 'Client: ' + self.customer_name
     print ('post_init...')
开发者ID:jerome76,项目名称:web-prototype,代码行数:18,代码来源:POSScreen.py

示例9: load_plot_configuration

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
 def load_plot_configuration(self):
     config = ConfigParser.get_configparser('app')
     self.plot_time_unit = config.getdefault('plot units', 'time', 'hours')
     self.plot_temp_unit = config.getdefault('plot units', 'temp', 'bar')
     self.plot_pres_unit = config.getdefault('plot units', 'pres', 'Fahrenheit')
     if self.profile:
         self.__calculate_x_ticks_major()
     if self.profile_has_been_selected:
         if self.current_plot == "temp":
             self.__makePresGraph()
             self.__makeTempGraph()
             self.showTempGraph()
         else:
             self.__makeTempGraph()
             self.__makePresGraph()
             self.showPresGraph()
开发者ID:pEEcor,项目名称:presse,代码行数:18,代码来源:main.py

示例10: check_for_update

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
    def check_for_update(self):
        config = ConfigParser.get_configparser('app')
        # 0 = checking, 1 not checking
        perform_update = config.getdefaultint('update', 'update', 0)
        if perform_update == 1:
            cwd = os.getcwd()
            abs_path = os.path.join(cwd, __file__)
            # cut off filename and directory
            parent_dir = os.path.split(os.path.split(abs_path)[0])[0]
            script_dir = os.path.join(parent_dir, 'script')
            src_dir = os.path.join(parent_dir, "src")

            # quit program, execute shell script, which updates the programm
            # and restarts it afterwards
            update_script = script_dir + "/update.sh"
            main_py = src_dir + "/main.py"
            subprocess.call(["bash", update_script, str(os.getpid()), main_py])
开发者ID:pEEcor,项目名称:presse,代码行数:19,代码来源:main.py

示例11: upload_payslips

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
    def upload_payslips(self, fn, pb_inc, *args):
        def on_success(req, result):
            self.pb.value += pb_inc
            print("Progressbar is on {0}%".format(self.pb.value))
            try:
                os.remove(fn)
            except OSError:
                print(traceback.format_exc())
                print "POSScreen.upload_payslips() on_success: no such file or directory"
            if self.pb.value >= 99.9:
                self.popup.dismiss()
                self.parent.parent.parent.update_icon(True)

        def on_failure(req, result):
            on_error(req, result)

        def on_error(req, result):
            self.pb.value += pb_inc
            print("Progressbar is on {0}%".format(self.pb.value))
            if self.pb.value >= 99.9:
                self.popup.dismiss()
                self.parent.parent.parent.update_icon(False)

        try:
            print ("POSScreen.upload_payslips()" + fn + ' ' + str(pb_inc))
            config = ConfigParser.get_configparser(name='app')
            print(config.get('serverconnection', 'server.url'))
            saleurl = config.get('serverconnection', 'server.url') + "pos/sale/"
            with open(fn) as data_file:
                result = json.load(data_file)
                file_param = dict([])
                file_param['filename'] = fn
                result['filename'] = file_param
                data_json = json.dumps(result)
                headers = {'Content-type': 'application/jsonrequest', 'Accept': 'application/jsonrequest'}
                UrlRequest(url=saleurl, on_success=on_success, on_failure=on_failure, on_error=on_error,
                           req_headers=headers, req_body=data_json)
        except Exception:
            print(traceback.format_exc())
            print "POSScreen.upload_payslips() Error: Could not upload payslip"
开发者ID:jerome76,项目名称:web-prototype,代码行数:42,代码来源:POSScreen.py

示例12: do_search

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
    def do_search(self):
        def on_success(req, result):
            print ('search success.')
            for i in result['result']:
                code = str(i['code'])
                if code == '':
                    code = '200001'
                btn = ImageButton(source='./products/'+code+'-small.png', id=code, text=str(i['id']),
                                  size_hint_y=None, width=300, height=100)
                btn.bind(on_press=self.do_add_item)
                self.products_search_list.append(btn)
                self.grid_layout_search_wid.add_widget(btn)
                self.tabbed_panel_wid.switch_to(self.tab_search_wid)
            self.grid_layout_search_wid.height = (len(result['result'])/4+4)*110

        if len(self.products_search_list) > 0:
            for n in self.products_search_list:
                self.grid_layout_search_wid.remove_widget(n)
        self.products_search_list = []
        config = ConfigParser.get_configparser(name='app')
        producturl = config.get('serverconnection', 'server.url') + "pos/product/" + self.text_input_wid.text
        UrlRequest(producturl, on_success)
开发者ID:togobananas-semilimes,项目名称:milliondog_website,代码行数:24,代码来源:POSScreen.py

示例13: on_pre_enter

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
 def on_pre_enter(self):
     def on_success(req, result):
         with open('customers.json', 'w') as fp:
             json.dump(result, fp)
             fp.close()
         self.products_json = result
         print ('customers loaded.')
         for i in result['result']:
             btn = Button(id=str(i['id']), text=i['name'], size_hint_y=None, width=200, height=48)
             btn.bind(on_press=self.do_action)
             print ('add customer ' + str(i['id']))
             self.customer_list_wid.add_widget(btn)
         self.customer_list_wid.height = (len(result['result'])+4)*50
     try:
         print("Select Customer")
         self.label_wid.text = self.manager.get_screen('posscreen').customer_id
         # clear customer
         config = ConfigParser.get_configparser(name='app')
         print(config.get('serverconnection', 'server.url'))
         customerurl = config.get('serverconnection', 'server.url') + "pos/customers/"
         UrlRequest(customerurl, on_success)
     except:
         print "Error: Could not load products"
开发者ID:togobananas-semilimes,项目名称:milliondog_website,代码行数:25,代码来源:main.py

示例14: on_pre_enter

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]

#.........这里部分代码省略.........

        def on_success_categories(req, result):
            with open('categories.json', 'w') as fp:
                json.dump(result, fp)
                fp.close()
            self.categories_json = result
            print ('categories loaded.')
            for i in result['result']:
                name = i['name']
                self.categories_list.append(i)
                if not getTabHeader(self.my_tabbed_panel_wid.tab_list, name):
                    th = TabbedPanelHeader(text=name)
                    self.my_tabbed_panel_wid.add_widget(th)
                    layout = GridLayout(cols=4, spacing=2, size_hint_y=None)
                    layout.bind(minimum_height=layout.setter('height'))
                    root = ScrollView()
                    root.add_widget(layout)
                    th.content = root
                print ('add online category ' + name)

        def on_failure_categories(req, result):
            on_error_categories(req, result)

        def on_error_categories(req, result):
            self.update_icon(False)
            print 'could not load categories'
            try:
                with open('categories.json') as data_file:
                    result = json.load(data_file)
                    self.categories_json = result
                for i in result['result']:
                    name = i['name']
                    self.categories_list.append(i)
                    if not getTabHeader(self.my_tabbed_panel_wid.tab_list, name):
                        th = TabbedPanelHeader(text=name)
                        self.my_tabbed_panel_wid.add_widget(th)
                        layout = GridLayout(cols=4, spacing=2, size_hint_y=None)
                        layout.bind(minimum_height=layout.setter('height'))
                        root = ScrollView()
                        root.add_widget(layout)
                        th.content = root
                        print ('add local category ' + name)
            except:
                traceback.print_exc(file=sys.stdout)

        def on_success_currencies(req, result):
            with open('currencies.json', 'w') as fp:
                json.dump(result, fp)
                fp.close()
            self.currencies_json = result
            print ('currencies loaded.')
            for i in result['result']:
                rate = Decimal(i['rate'])
                if rate == Decimal(1.000):
                    self.default_currency = i['code']
                    print ('set default currency ' + i['code'])
                if rate > Decimal(0.00000):
                    self.currencies_list.append(i)
                    print ('add currency ' + i['code'])

        def on_failure_currencies(req, result):
            on_error_currencies(req, result)

        def on_error_currencies(req, result):
            self.update_icon(False)
            print 'could not load currencies'
            try:
                with open('currencies.json') as data_file:
                    result = json.load(data_file)
                    self.currencies_json = result
                for i in result['result']:
                    rate = Decimal(i['rate'])
                    if rate == Decimal(1.000):
                        self.default_currency = i['code']
                        print ('set default currency ' + i['code'])
                    if i['rate'] > Decimal(0.00000):
                        self.currencies_list.append(i)
            except:
                traceback.print_exc(file=sys.stdout)
        try:
            self.btn_order_id_wid.text = str(self.order_id)
            self.username = self.manager.get_screen('main').textinput_user_wid.text
            config = ConfigParser.get_configparser(name='app')
            print(config.get('serverconnection', 'server.url'))
            hideoutofstockitems = config.get('section1', 'hide_out_of_stock_items')
            producturl = config.get('serverconnection', 'server.url') + "pos/products/" + hideoutofstockitems
            if len(self.products_list) == 0:
                UrlRequest(url=producturl, on_success=on_success, on_failure=on_failure, on_error=on_error)
            categoryurl = config.get('serverconnection', 'server.url') + "pos/categories/"
            if len(self.categories_list) == 0:
                UrlRequest(url=categoryurl, on_success=on_success_categories, on_failure=on_failure_categories,
                           on_error=on_error_categories)
            currencyurl = config.get('serverconnection', 'server.url') + "pos/currency/"
            if len(self.currencies_list) == 0:
                UrlRequest(url=currencyurl, on_success=on_success_currencies, on_failure=on_failure_currencies,
                       on_error=on_error_currencies)

        except:
            traceback.print_exc(file=sys.stdout)
        print "Initialize products selection"
开发者ID:jerome76,项目名称:web-prototype,代码行数:104,代码来源:POSScreen.py

示例15: load_process_configuration

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import get_configparser [as 别名]
 def load_process_configuration(self):
     config = ConfigParser.get_configparser('app')
     self.log_interval = int(config.getdefault('process', "logInterval", "10"))
     self.sub_size_unit = config.getdefault("process", "subsize", "mm")
开发者ID:pEEcor,项目名称:presse,代码行数:6,代码来源:main.py


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