python保存save任意格式_Python config.save方法代码示例

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

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

示例1: ask_user

​点赞 3

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def ask_user(preferences = {}):

def add_argument(name, help, **kwargs):

kwargs['required'] = kwargs.get('required', not (name in preferences))

kwargs['default'] = kwargs.get('default', preferences.get(name, None))

parser.add_argument('--' + name, help=help, **kwargs)

parser = argparse.ArgumentParser(description="Access MeuAlelo system to extract this month's operations")

add_argument('cpf', "CPF with only numbers")

add_argument('password', "Password used to access the system")

add_argument('card', "Which card from the list we want to access", type=int, default=0)

add_argument('save', "If present saves the provided configurations in an init file",

required=False, action="store_true")

add_argument('month', "Specify for which month transactions must be converted",

required=False, type=int)

return vars(parser.parse_args())

开发者ID:dantas,项目名称:alelo_ofx,代码行数:19,

示例2: handleKlok

​点赞 3

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def handleKlok(self):

neo = self.neo

if config.dirty:

self.updateFromConfig()

config.save()

now = time.localtime()

hour = (now[3] + config.get("timeoffset",1) ) % 12

h = hour * 5 + (now[4] + 6)/12;

h = int (h % 60)

neo.clearBuffer()

neo.setPixel(29, self.stateColor)

neo.setPixel(31, self.stateColor)

neo.setPixel( 0, self.qColor);

neo.setPixel( 15, self.qColor);

neo.setPixel( 30, self.qColor);

neo.setPixel( 45, self.qColor);

neo.addPixel(now[5] , self.sColor)

neo.addPixel(now[4], self.mColor)

neo.addPixel(h, self.hColor)

neo.writeBuffer()

开发者ID:smeenka,项目名称:esp32,代码行数:23,

示例3: startap

​点赞 3

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def startap(ssid = None,pw = None):

if ssid:

config.put("ap_ssid",ssid)

ssid = config.get("ap_ssid","micropython2")

if pw:

config.put("ap_pw",pw)

pw = config.get("ap_pw","12345678")

config.save()

log.info("Starting AP with ssid:%s",ssid)

ap.active(False)

time.sleep_ms(100)

ap.active(True)

time.sleep_ms(100)

ap.config(essid=ssid, channel=11,password=pw)

开发者ID:smeenka,项目名称:esp32,代码行数:19,

示例4: save_config

​点赞 3

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def save_config(self, *args):

header = "save_config(): "

print header," saving..."

sys.stdout.flush()

# read parameters from GUI first!

self.get_param()

config.save(self.param)

print header," done!"

sys.stdout.flush()

return

# ------------------------------------------------------------------

开发者ID:sid5432,项目名称:pm-fiber-birefringence,代码行数:19,

示例5: main

​点赞 3

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def main():

PiCamera.set(exposure=config.exposure, resolution=config.resolution)

config.resolution = PiCamera.getResolution()

config.degPerPxl = np.divide(config.nativeAngle, config.resolution)

if not config.edited:

GripRunner.editCode()

frameNum = 1

while True:

image = PiCamera.getImage()

contours = GripRunner.run(image)

targets = filterContoursFancy(contours, image=image)

isVisible, angleToGoal, distance = findSpike(targets)

if config.debug:

Printing.printResults(contours=contours, distance=distance, angleToGoal=angleToGoal, isVisible=isVisible)

if config.save:

Printing.drawImage(image, contours, targets, center)

Printing.save(image)

try:

NetworkTabling.publishToTables(isVisible=isVisible, angleToGoal=angleToGoal, distance=distance, frameNum=frameNum)

except Exception as error:

if config.debug:

print error

frameNum += 1

开发者ID:RoboticsTeam4904,项目名称:2017-Vision,代码行数:25,

示例6: save_if_necessary

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def save_if_necessary(preferences):

if preferences['save']:

del preferences['save']

del preferences['month']

config.save(preferences)

开发者ID:dantas,项目名称:alelo_ofx,代码行数:7,

示例7: load_preferences

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def load_preferences():

preferences = config.read()

preferences['month'] = None

preferences['card'] = int(preferences.get('card', 0))

preferences['save'] = False

return preferences

开发者ID:dantas,项目名称:alelo_ofx,代码行数:8,

示例8: train

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def train():

cleanup.cleanup()

c.save(c.work_dir)

data_loader = TextLoader(c.work_dir, c.batch_size, c.seq_length)

with open(os.path.join(c.work_dir, 'chars_vocab.pkl'), 'wb') as f:

cPickle.dump((data_loader.chars, data_loader.vocab), f)

model = Model(c.rnn_size, c.num_layers, len(data_loader.chars), c.grad_clip, c.batch_size, c.seq_length)

with tf.Session() as sess:

tf.initialize_all_variables().run()

saver = tf.train.Saver(tf.all_variables())

for e in range(c.num_epochs):

sess.run(tf.assign(model.lr, c.learning_rate * (c.decay_rate ** e)))

data_loader.reset_batch_pointer()

state = model.initial_state.eval()

for b in range(data_loader.num_batches):

start = time.time()

x, y = data_loader.next_batch()

feed = {model.input_data: x, model.targets: y, model.initial_state: state}

train_loss, state, _ = sess.run([model.cost, model.final_state, model.train_op], feed)

end = time.time()

print("{}/{} (epoch {}), train_loss = {:.3f}, time/batch = {:.3f}"

.format(e * data_loader.num_batches + b,

c.num_epochs * data_loader.num_batches,

e, train_loss, end - start))

if (e * data_loader.num_batches + b) % c.save_every == 0:

checkpoint_path = os.path.join(c.work_dir, 'model.ckpt')

saver.save(sess, checkpoint_path, global_step=e * data_loader.num_batches + b)

print("model saved to {}".format(checkpoint_path))

开发者ID:dvictor,项目名称:lstm-poetry,代码行数:33,

示例9: connect2ap

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def connect2ap(ssid= None,pw = None):

""" If pw is None get the password from the config file

If pw is not None, write ssid,pw to the config file

If ip is None in config file choose dhcp config

else get ip.

If gw is None it is assumed as 192.168.2.254,

If dns is None it is assumed as 192.168.2.254,

Deactivate the wlan, wait 1 second and activate with given ssid and pw

"""

log.info("Connecting to ap %s",ssid)

if not ssid:

ssid = config.get("ssid","xxxx")

else:

config.put("ssid",ssid)

if not pw:

pw = config.get(ssid,"geheim")

else:

config.put(ssid,pw)

ip = config.get("wlan_ip")

gw = config.get("wlan_gw","192.168.2.254")

dns = config.get("wlan_dns","192.168.2.254")

config.save()

wlan.active(False)

wlan.active(True)

if ip:

wconf = ( ip,'255.255.255.0',gw,dns)

wlan.ifconfig( wconf )

wlan.connect(ssid,pw)

开发者ID:smeenka,项目名称:esp32,代码行数:36,

示例10: on_enable_gae_proxy

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def on_enable_gae_proxy(self, widget=None, data=None):

win32_proxy_manager.set_proxy("127.0.0.1:8087")

config.set(["modules", "launcher", "proxy"], "gae")

config.save()

开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:6,

示例11: on_enable_pac

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def on_enable_pac(self, widget=None, data=None):

win32_proxy_manager.set_proxy("http://127.0.0.1:8086/proxy.pac")

config.set(["modules", "launcher", "proxy"], "pac")

config.save()

开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:6,

示例12: on_disable_proxy

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def on_disable_proxy(self, widget=None, data=None):

win32_proxy_manager.disable_proxy()

config.set(["modules", "launcher", "proxy"], "disable")

config.save()

开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:6,

示例13: process_data_files

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def process_data_files():

#TODO: fix bug

#new_config = get_new_new_config()

#config.load()

#config.config["modules"]["gae_proxy"]["current_version"] = new_config["modules"]["gae_proxy"]["current_version"]

#config.config["modules"]["launcher"]["current_version"] = new_config["modules"]["launcher"]["current_version"]

config.save()

开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:9,

示例14: enableAutoProxy_

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def enableAutoProxy_(self, _):

try:

helperDisableGlobalProxy(currentService)

helperEnableAutoProxy(currentService)

except:

disableGlobalProxyCommand = getDisableGlobalProxyCommand(currentService)

enableAutoProxyCommand = getEnableAutoProxyCommand(currentService)

executeCommand = 'do shell script "%s;%s" with administrator privileges' % (disableGlobalProxyCommand, enableAutoProxyCommand)

xlog.info("try enable auto proxy:%s", executeCommand)

subprocess.call(['osascript', '-e', executeCommand])

config.set(["modules", "launcher", "proxy"], "pac")

config.save()

self.updateStatusBarMenu()

开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:16,

示例15: disableProxy_

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def disableProxy_(self, _):

try:

helperDisableAutoProxy(currentService)

helperDisableGlobalProxy(currentService)

except:

disableAutoProxyCommand = getDisableAutoProxyCommand(currentService)

disableGlobalProxyCommand = getDisableGlobalProxyCommand(currentService)

executeCommand = 'do shell script "%s;%s" with administrator privileges' % (disableAutoProxyCommand, disableGlobalProxyCommand)

xlog.info("try disable proxy:%s", executeCommand)

subprocess.call(['osascript', '-e', executeCommand])

config.set(["modules", "launcher", "proxy"], "disable")

config.save()

self.updateStatusBarMenu()

开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:16,

示例16: ignore_module

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def ignore_module(module, new_version):

config.set(["modules", module, "ignore_version"], str(new_version))

config.save()

开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:5,

示例17: check_new_machine

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def check_new_machine():

current_path = os.path.dirname(os.path.abspath(__file__))

if current_path != config.get(["update", "last_path"], ""):

config.set(["update", "last_path"], current_path)

config.save()

if sys.platform == "win32" and platform.release() == "XP":

notify_install_tcpz_for_winXp()

xlog.info("generate desktop shortcut")

create_desktop_shortcut()

开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:14,

示例18: generate_new_uuid

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def generate_new_uuid():

xx_net_uuid = str(uuid.uuid4())

config.set(["update", "uuid"], xx_net_uuid)

xlog.info("generate uuid:%s", xx_net_uuid)

config.save()

开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:7,

示例19: prepare_quit

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def prepare_quit(window):

"""Save the window state and settings file."""

config.save()

开发者ID:3D1T0R,项目名称:PortableApps.com-DevelopmentToolkit,代码行数:5,

示例20: main

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def main():

WebCam.set(exposure=config.exposure, resolution=config.resolution, contrast=config.contrast, gain=config.gain)

autocalibrate.calibrate()

config.resolution = WebCam.getResolution()

config.degPerPxl = np.divide(config.nativeAngle, config.resolution)

if not config.edited:

GripRunner.editCode()

if config.display:

cv2.namedWindow("Contours Found")

frameNum = 1

while True:

if NetworkTabling.checkForCalibrate():

print "CALIBRATING the camera due to button press"

autocalibrate.calibrate()

NetworkTabling.putCalibrated()

image = WebCam.getImage()

contours = GripRunner.run(image)

targets = filterContoursFancy(contours)

isVisible, angleToGoal, distance = findSpike(targets)

if config.debug:

Printing.printResults(contours=contours, distance=distance, angleToGoal=angleToGoal, isVisible=isVisible)

if config.save or config.display:

Printing.drawImage(image, contours, targets)

if config.save:

Printing.save(image)

if config.display:

Printing.display(image)

try:

NetworkTabling.publishToTables(isVisible=isVisible, angleToGoal=angleToGoal, distance=distance, frameNum=frameNum)

except Exception as error:

if config.debug:

print error

frameNum += 1

if display:

cv2.destroyAllWindows()

开发者ID:RoboticsTeam4904,项目名称:2017-Vision,代码行数:40,

示例21: main

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def main():

if not config.edited:

GripRunner.editCode()

if config.display:

cv2.namedWindow("Contours Found")

image = cv2.imread(config.sampleImage)

config.resolution = image.shape[1], image.shape[0]

config.degPerPxl = np.divide(config.nativeAngle, config.resolution)

contours = GripRunner.run(image)

targets = filterContoursFancy(contours, image=image)

isVisible, angleToGoal, distance = findSpike(targets)

if config.debug:

Printing.printResults(contours=contours, distance=distance, angleToGoal=angleToGoal, isVisible=isVisible)

if config.save or config.display:

Printing.drawImage(image, contours, targets)

if config.save:

Printing.save(image)

if config.display:

Printing.display(image)

try:

NetworkTabling.publishToTables(isVisible=isVisible, angleToGoal=angleToGoal, distance=distance)

except Exception as error:

if config.debug:

print error

if config.display:

cv2.waitKey(0)

cv2.destroyAllWindows()

开发者ID:RoboticsTeam4904,项目名称:2017-Vision,代码行数:29,

示例22: install_module

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import save [as 别名]

def install_module(module, new_version):

import module_init

import os, subprocess, sys

current_path = os.path.dirname(os.path.abspath(__file__))

new_module_version_path = os.path.abspath( os.path.join(current_path, os.pardir, os.pardir, module, new_version))

#check path exist

if not os.path.isdir(new_module_version_path):

xlog.error("install module %s dir %s not exist", module, new_module_version_path)

return

#call setup.py

setup_script = os.path.join(new_module_version_path, "setup.py")

if not os.path.isfile(setup_script):

xlog.warn("update %s fail. setup script %s not exist", module, setup_script)

return

config.set(["modules", module, "current_version"], str(new_version))

config.save()

if module == "launcher":

module_init.stop_all()

import web_control

web_control.stop()

subprocess.Popen([sys.executable, setup_script], shell=False)

os._exit(0)

else:

xlog.info("Setup %s version %s ...", module, new_version)

try:

module_init.stop(module)

subprocess.call([sys.executable, setup_script], shell=False)

xlog.info("Finished new version setup.")

xlog.info("Restarting new version ...")

module_init.start(module)

except Exception as e:

xlog.error("install module %s %s fail:%s", module, new_version, e)

开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:46,

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值