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


Python config.config方法代码示例

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


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

示例1: __init__

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def __init__(self):
    self.currenttime = time.localtime()
    printtime = time.strftime("%Y%m%d%H%M%S ", self.currenttime)
    self.logfile = open(config['files']['logfile'],'at',buffering=1)
    self.sampletime = time.time()
    self.prevtime = time.localtime()
    self.summary=loadsummary()

#      summary = open('/media/75cc9171-4331-4f88-ac3f-0278d132fae9/summary','w')
#      pickle.dump(hivolts, summary)
#      pickle.dump(lowvolts, summary)
#      summary.close()
    if self.summary['hour']['timestamp'][0:10] != printtime[0:10]:
      self.summary['hour'] = deepcopy(self.summary['current'])
    if self.summary['currentday']['timestamp'][0:8] != printtime[0:8]:
      self.summary['currentday'] = deepcopy(self.summary['current'])
    if self.summary['monthtodate']['timestamp'][0:6] != printtime[0:6]:
      self.summary['monthtodate'] = deepcopy(self.summary['current'])
    if self.summary['yeartodate']['timestamp'][0:4] != printtime[0:4]:
      self.summary['yeartodate'] = deepcopy(self.summary['current']) 
开发者ID:simat,项目名称:BatteryMonitor,代码行数:22,代码来源:summary.py

示例2: writesummary

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def writesummary(self):
    """ Write summary file """

    for section in summaryfile.sections():
      for option in summaryfile.options(section):
        summaryfile.set(section, option, str(self.summary[section][option]))
    of = open(config['files']['summaryfile'],'w')
    summaryfile.write(of)
    of.close()

#  def writehour(self, data):
#    hoursummaryfile=open('/media/75cc9171-4331-4f88-ac3f-0278d132fae9/hoursummary','a')
#    hoursummaryfile.write(data)
#    hoursummaryfile.close()
#    logsummary.set('alltime', 'maxvoltages') = round(max(literal_eval(logsummary.get('currentday','maxvoltages')),literal_eval(logsummary.get(),2)
#    logsummary.set('alltime', 'minvoltages') = round(min(literal_eval(logsummary.get('currentday','minvoltages')),batdata.batvoltsav[8]),2)
#    logsummary.set('alltime', 'ah') = round(max(literal_eval(logsummary.get('currentday','ah'))[1], batdata.soc/1000),2)
#    logsummary.set('alltime', 'ah') = round(min(literal_eval(logsummary.get('currentday','ah'))[0], batdata.soc/1000),2)
#    logsummary.set('alltime', 'current') = round(max(literal_eval(logsummary.get('alltime','current'))[1], batdata.currentav[-3]/1000),2)
#    logsummary.set('alltime', 'current') = round(min(literal_eval(logsummary.get('alltime','current'))[0], batdata.currentav[-3]/1000),2) 
开发者ID:simat,项目名称:BatteryMonitor,代码行数:22,代码来源:summary.py

示例3: scanalarms

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def scanalarms(self,batdata):
#    self.timedate = localtime()
#    print (self.timedate.tm_hour)
    for i in config['alarms']:
      if not self.alarmtriggered[i]:
        exec(config['alarms'][i][1])
  #      log.debug('{}{}{}'.format(self.test,batdata.maxcellv,batdata.lastmaxcellv))
        if self.test:
    #            sys.stderr.write('Alarm 1 triggered')
          log.info('alarm {} triggered'.format(i))
          self.alarmtriggered[i]=True
          exec(config['alarms'][i][2])

      if self.alarmtriggered[i]:
        exec(config['alarms'][i][3])
        if self.test:
          log.info('alarm {} reset'.format(i))
          self.alarmtriggered[i]=False
          exec(config['alarms'][i][4]) 
开发者ID:simat,项目名称:BatteryMonitor,代码行数:21,代码来源:alarms.py

示例4: getbmsdat

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def getbmsdat(self,port,command):
    """ Issue BMS command and return data as byte data """
    """ assumes data port is open and configured """
    for i in range(5):
      try:
        port.write(command)
        reply = port.read(4)
#        raise serial.serialutil.SerialException('hithere')
        break
      except serial.serialutil.SerialException as err:
        errfile=open(config['files']['errfile'],'at')
        errfile.write(time.strftime("%Y%m%d%H%M%S ", time.localtime())+str(err.args)+'\n')
        errfile.close()

  #  print (reply)
    x = int.from_bytes(reply[3:5], byteorder = 'big')
#    print (x)
    data = port.read(x)
    end = port.read(3)
#    print (data)
    return data 
开发者ID:simat,项目名称:BatteryMonitor,代码行数:23,代码来源:getbms.py

示例5: findbms

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def findbms(self):
    """Scan ports to find BMS port"""

    self.bmsport=""
    for dev in glob.glob(config['Ports']['bmsport']):
      for i in range(2):
        try:
          self.openbms(dev)
          reply=self.getbmsdat(self.port,b'\x05\x00')
          if reply.decode('ascii','strict')==self.sn:
            self.bmsport=dev
            break
        except serial.serialutil.SerialException:
          pass
        finally:
          self.port.close()
      if self.bmsport!="":
        break
    if self.bmsport=="":
      raise Exception("Couldn't find BMS hardware name {}".format(self.sn)) 
开发者ID:simat,项目名称:BatteryMonitor,代码行数:22,代码来源:bms.py

示例6: findpip

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def findpip(self):
    """Scan ports to find PIP port"""

    self.pipport=""
    for dev in glob.glob(config['Ports']['pipport']):
      for i in range(2):
        try:
          self.openpip(dev)
          self.sendcmd("QID",18)
          if self.reply[1:15].decode('ascii','strict')==str(self.sn):
            self.pipport=dev
            break
        except serial.serialutil.SerialException:
          pass
        finally:
          self.port.close
      if self.pipport!="":
        break
    if self.pipport=="":
      raise serial.serialutil.SerialException("Couldn't find PIP sn {}".format(self.sn)) 
开发者ID:simat,项目名称:BatteryMonitor,代码行数:22,代码来源:pip.py

示例7: solaravailable

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def solaravailable(batdata):
  """Returns max amount of surpus solar energy available without using battery Power
     Calculates the difference between amount of power being consumed vesus
     power that could be consumed to get battery current=IBatZero"""

  ibatminuteav=batdata.ibatminute/batdata.ibatnuminmin
  batdata.ibatminute = 0.0
  batdata.ibatnuminmin = 0

  iavailable=(IBatZero-ibatminuteav)
  soc=1-batdata.socadj/config['battery']['capacity']
  iavailable=iavailable+config['battery']['maxchargerate']* \
             (soc-config['battery']['targetsoc'])*20
  pwravailable=iavailable*batdata.batvoltsav[config['battery']['numcells']+1]
#  print (iavailable,soc,pwravailable)
  return pwravailable 
开发者ID:simat,项目名称:BatteryMonitor,代码行数:18,代码来源:demandmanager.py

示例8: create_app

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def create_app(config_name):
    app = Flask(__name__)
    #app.config['JSON_AS_ASCII'] = False
    # 进行app配置 把自己的config设定导入到app中
    app.config.from_object(config[config_name])

    # 初始化app配置
    config[config_name].init_app(app)

    db.init_app(app)
    db.app = app

    # 初始化apscheduler
    scheduler.init_app(app)
    scheduler.start()

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .job import main as job_blueprint
    app.register_blueprint(job_blueprint,url_prefix='/v1/cron/job')

    return app 
开发者ID:yangmv,项目名称:CTask,代码行数:25,代码来源:__init__.py

示例9: train_network

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def train_network(self, learning_rate, decay_rate, start_epoch=None):
        # weights_path = "weights/{0}-rerun-test.h5".format(learning_rate)
        # log_path = "logs/{0}-rerun-test".format(learning_rate)
        tensorboard = keras.callbacks.TensorBoard(log_dir=config['log_path'],
                                                  histogram_freq=0,
                                                  write_graph=True,
                                                  write_images=False)
        checkpointer = keras.callbacks.ModelCheckpoint(filepath=config['weights_path'],
                                                       verbose=1,
                                                       save_best_only=True)
        self.model.fit_generator(self.next_train_batch(chunk_size=16),
                                 samples_per_epoch=int(self.train_size/5),
                                 nb_epoch=self.num_epochs,
                                 validation_data=self.next_validation_batch(chunk_size=32),
                                 nb_val_samples=int(self.validation_size/5),
                                 callbacks=[checkpointer, tensorboard])

# learning_rate = 0.001
# decay_rate = 0.001
# neural_net = NeuralNetwork(learning_rate, decay_rate) 
开发者ID:nocturnaltortoise,项目名称:recaptcha-cracker,代码行数:22,代码来源:nn.py

示例10: resize_images

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def resize_images(paths):
        for path in paths:
            if os.path.isfile(path) and os.path.getsize(path) > 0:
                filename, ext = os.path.splitext(path)
                image_size = "_{0}".format(config['image_size'])
                new_filename = filename + image_size + ext
                if not os.path.exists(new_filename) or os.path.getsize(new_filename) == 0:
                    # if the file hasn't been resized
                    # or the resized version is corrupt (i.e. zero size)
                    if image_size not in filename:
                        try:
                            image = Image.open(path)
                            image = image.resize(config['image_size_tuple'])
                            image.save(filename + image_size + ext)
                        except OSError:
                            print("OSError caused by file at {0}".format(path))
                            continue
                            # if OSError:
                            # cannot identify image file occurs despite above checks, skip the image 
开发者ID:nocturnaltortoise,项目名称:recaptcha-cracker,代码行数:21,代码来源:preprocessors.py

示例11: colour_images

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def colour_images(paths):
        for path in paths:
            if os.path.isfile(path) and os.path.getsize(path) > 0:
                filename, ext = os.path.splitext(path)
                image_size = "_{0}".format(config['image_size'])
                if image_size in filename:
                    try:
                        image = Image.open(path)
                        if image.mode != "RGB":
                            image = image.convert("RGB")
                            image.save(filename + ext)
                    except OSError:
                        print("OSError caused by file at {0}".format(path))
                        continue
                        # if OSError:
                        # cannot identify image file occurs despite above checks, skip the image 
开发者ID:nocturnaltortoise,项目名称:recaptcha-cracker,代码行数:18,代码来源:preprocessors.py

示例12: run

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def run():
    """
    生产模式启动命令函数
    To use: python3 manager.py run
    """
    app.logger.setLevel(app.config.get('LOG_LEVEL', logging.INFO))
    service_config = {
        'bind': app.config.get('BIND', '0.0.0.0:5000'),
        'workers': app.config.get('WORKERS', cpu_count() * 2 + 1),
        'worker_class': 'gevent',
        'worker_connections': app.config.get('WORKER_CONNECTIONS', 10000),
        'backlog': app.config.get('BACKLOG', 2048),
        'timeout': app.config.get('TIMEOUT', 60),
        'loglevel': app.config.get('LOG_LEVEL', 'info'),
        'pidfile': app.config.get('PID_FILE', 'run.pid'),
    }
    StandaloneApplication(app, service_config).run() 
开发者ID:lalala223,项目名称:flask-restful-example,代码行数:19,代码来源:manager.py

示例13: check_OP_1_Connection

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def check_OP_1_Connection():
    connected = Image.new('1', (128, 64))
    draw = ImageDraw.Draw(connected)
    draw.text((0, 25), "Connecting.....", font=getFont(), fill='white')
    displayImage(connected)

    # if is_connected():
    if do_mount("OP1"):
        connected = Image.new('1', (128, 64))
        draw = ImageDraw.Draw(connected)
        draw.text((0, 25), "Connected", font=getFont(), fill='white')
        displayImage(connected)
        return True
    else:
        connected = Image.new('1', (128, 64))
        draw = ImageDraw.Draw(connected)
        draw.text((0, 25), "No Connection!", font=getFont(), fill='white')
        displayImage(connected)
        config["USB_Mount_Path"] = ""
        config["OP_1_Mounted_Dir"] = ""
        time.sleep(1)
        return False 
开发者ID:adwuard,项目名称:OP_Manager,代码行数:24,代码来源:OP_1_Connection.py

示例14: check_OP_Z_Connection

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def check_OP_Z_Connection():
    connected = Image.new('1', (128, 64))
    draw = ImageDraw.Draw(connected)
    draw.text((0, 25), "Connecting.....", font=getFont(), fill='white')
    displayImage(connected)
    if do_mount("OPZ"):
        connected = Image.new('1', (128, 64))
        draw = ImageDraw.Draw(connected)
        draw.text((0, 25), "Connected", font=getFont(), fill='white')
        displayImage(connected)
        time.sleep(1)
        return True
    else:
        connected = Image.new('1', (128, 64))
        draw = ImageDraw.Draw(connected)
        draw.text((0, 25), "No Connection!", font=getFont(), fill='white')
        displayImage(connected)
        config["USB_Mount_Path"] = ""
        time.sleep(1)
        return False 
开发者ID:adwuard,项目名称:OP_Manager,代码行数:22,代码来源:OP_1_Connection.py

示例15: autoMountUnmontThread

# 需要导入模块: import config [as 别名]
# 或者: from config import config [as 别名]
def autoMountUnmontThread():
    while 1:
        print("Unmount Checking Thread")
        # if config["OP_1_Mounted_Dir"] == "":
        #     if do_mount("OP1"):
        #         print("============ Thread OP1 Mounted ==============")
        #     else:
        #         print("============ Thread Waiting OP1 ==============")
        # if config["OP_Z_Mounted_Dir"] == "":
        #     if do_mount("OPZ"):
        #         print("============ Thread OPZ Mounted ==============")
        #     else:
        #         print("============ Thread Waiting OPZ ==============")
        # Device Mounted check for unmount
        if config["OP_1_Mounted_Dir"] != "":
            if not os.listdir(config["OP_1_Mounted_Dir"]):
                unmountdevice(config["OP_1_Mounted_Dir"])
                config["OP_1_Mounted_Dir"] = ""
                print("============ Thread OP1 Auto Unmount==============")
        if config["OP_Z_Mounted_Dir"] != "":
            if not os.listdir(config["TargetOpZMountDir"]):
                unmountdevice(config["OP_Z_Mounted_Dir"])
                config["OP_z_Mounted_Dir"] = ""
                print("============ Thread OPZ Auto Unmount==============")
        time.sleep(3) 
开发者ID:adwuard,项目名称:OP_Manager,代码行数:27,代码来源:OP_1_Connection.py


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