本文整理汇总了Python中config.ConfigManager类的典型用法代码示例。如果您正苦于以下问题:Python ConfigManager类的具体用法?Python ConfigManager怎么用?Python ConfigManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_resizer
def update_resizer(self, widget, event):
self.resizer.set_position(self.get_allocation().height)
if not self.is_fullscreen:
new_percent = int((self.get_allocation().height * 1.0) / self.screen.get_height() * 100.0)
ConfigManager.set_conf('height', str(new_percent))
ConfigManager.save_config()
示例2: snapshot
def snapshot(self):
"""
@brief Save basic infos for next login.
@return Bool: whether operation succeed.
"""
try:
conf = {
'uuid': self.uuid,
'redirect_uri': self.redirect_uri,
'uin': self.uin,
'sid': self.sid,
'skey': self.skey,
'pass_ticket': self.pass_ticket,
'synckey': self.synckey,
'device_id': self.device_id,
'last_login': time.time(),
}
cm = ConfigManager()
Log.debug('save wechat config')
cm.set_wechat_config(conf)
# save cookie
Log.debug('save cookie')
if self.cookie:
self.cookie.save(ignore_discard=True)
# save contacts
Log.debug('save contacts')
self.save_contacts()
except Exception, e:
Log.error(traceback.format_exc())
return False
示例3: test_realize_path
def test_realize_path():
assert "/baz" == ConfigManager.realize_path("/foo/../bar/../baz")
os.path.abspath = Mock(return_value="/baz")
assert "/baz" == ConfigManager.realize_path("../baz")
os.path.expanduser = Mock(return_value="/home/foobar")
assert "/home/foobar" == ConfigManager.realize_path("~foobar/")
示例4: cannot_bind
def cannot_bind(app):
ConfigManager.set_conf('hide-on-start', False)
ConfigManager.set_conf('losefocus-hiding', False)
msgtext = _("Another application using '%s'. Please open preferences and change the shortcut key.") % ConfigManager.get_conf('global-key')
msgbox = Gtk.MessageDialog(app, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK, msgtext)
msgbox.run()
msgbox.destroy()
示例5: recover
def recover(self):
"""
@brief Recover from snapshot data.
@return Bool: whether operation succeed.
"""
cm = ConfigManager()
[self.uuid, self.redirect_uri, self.uin,
self.sid, self.skey, self.pass_ticket,
self.synckey, device_id, self.last_login] = cm.get_wechat_config()
if device_id:
self.device_id = device_id
self.base_request = {
'Uin': int(self.uin),
'Sid': self.sid,
'Skey': self.skey,
'DeviceID': self.device_id,
}
# set cookie
Log.debug('set cookie')
self.cookie = set_cookie(self.cookie_file)
return True
示例6: close_node
def close_node(self, widget):
parent = self.get_parent()
if type(parent) == VteObjectContainer:
return
container = parent
while type(container) != VteObjectContainer:
container = container.get_parent()
if parent.get_child1() == self:
sibling = parent.get_child2()
else:
sibling = parent.get_child1()
ConfigManager.remove_callback(self.update_ui)
parent.remove(sibling)
top_level = parent.get_parent()
if type(top_level) == VteObjectContainer:
top_level.remove(parent)
top_level.pack_start(sibling, True, True, 0)
else:
if top_level.get_child1() == parent:
top_level.remove(parent)
top_level.pack1(sibling, True, True)
else:
top_level.remove(parent)
top_level.pack2(sibling, True, True)
sibling.vte.grab_focus()
container.active_terminal = sibling
示例7: __init__
def __init__(self):
super(Gtk.HBox, self).__init__()
ConfigManager.add_callback(self.update_ui)
self.vte = Vte.Terminal()
self.pack_start(self.vte, True, True, 0)
if ConfigManager.get_conf('show-scrollbar'):
self.vscroll = Gtk.VScrollbar()
self.vscroll.set_adjustment(self.vte.get_vadjustment())
self.pack_end(self.vscroll, False, True, 0)
dir_conf = ConfigManager.get_conf('dir')
if dir_conf == '$home$':
run_dir = os.environ['HOME']
elif dir_conf == '$pwd$':
run_dir = os.getcwd()
else:
run_dir = dir_conf
self.vte.fork_command_full(
Vte.PtyFlags.DEFAULT,
run_dir,
ConfigManager.get_conf('shell').split(),
[],
GLib.SpawnFlags.DO_NOT_REAP_CHILD,
None,
None)
self.vte.connect('button-release-event', self.on_button_release)
self.update_ui()
示例8: override_gtk_theme
def override_gtk_theme(self):
css_provider = Gtk.CssProvider()
bg = Gdk.color_parse(ConfigManager.get_conf('color-background'))
bg_hex = '#%02X%02X%02X' % (int((bg.red/65536.0)*256), int((bg.green/65536.0)*256), int((bg.blue/65536.0)*256))
css_provider.load_from_data('''
#notebook GtkPaned
{
-GtkPaned-handle-size: %i;
}
GtkVScrollbar
{
-GtkRange-slider-width: 5;
}
GtkVScrollbar.trough {
background-image: none;
background-color: %s;
border-width: 0;
border-radius: 0;
}
GtkVScrollbar.slider, GtkVScrollbar.slider:prelight, GtkVScrollbar.button {
background-image: none;
border-width: 0;
background-color: alpha(#FFF, 0.4);
border-radius: 10px;
box-shadow: none;
}
''' % (ConfigManager.get_conf('seperator-size'), bg_hex))
style_context = Gtk.StyleContext()
style_context.add_provider_for_screen(self.screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
示例9: __init__
def __init__(self, progname=[ConfigManager.get_conf('shell')], run_dir=None, term_id=0):
super(Gtk.HBox, self).__init__()
ConfigManager.add_callback(self.update_ui)
self.progname = ' '.join(progname)
self.id = VteObjectContainer.handle_id(term_id)
self.parent = 0
self.vte = Vte.Terminal()
self.pack_start(self.vte, True, True, 0)
self.vscroll = Gtk.VScrollbar(self.vte.get_vadjustment())
self.pack_start(self.vscroll, False, False, 0)
self.fork_process(progname, run_dir)
for regex_string in regex_strings:
regex_obj = GLib.Regex.new(regex_string, 0, 0)
tag = self.vte.match_add_gregex(regex_obj, 0)
self.vte.match_set_cursor_type(tag, Gdk.CursorType.HAND2)
self.vte.connect('scroll-event', self.scroll_event)
self.vte.connect('child-exited', self.on_child_exited)
self.vte.connect('button-release-event', self.on_button_release)
self.vte.connect('increase-font-size', self.change_font_size, 0.1)
self.vte.connect('decrease-font-size', self.change_font_size, -0.1)
self.update_ui()
示例10: __init__
def __init__(self, db):
self.db = db
self.wechat = None # recieve `WeChat` class instance
# for call some wechat apis
# read config
cm = ConfigManager()
[self.upload_dir, self.data_dir, self.log_dir] = cm.setup_database()
示例11: WarpZoneListener
class WarpZoneListener(BaseListener):
default_config = {
'warpzones': [
{
'area': {
'min': [0, 0, 0],
'max': [1, 1, 1],
'world': 'world'
},
'to': {
'location': [2, 2, 2],
'world': 'world'
}
}
]
}
def __init__(self, plugin):
self.plugin = plugin
def onEnable(self):
self.config_manager = ConfigManager(path.join(self.plugin.getDataFolder().getAbsolutePath(), 'warpzones.yml'), default=self.default_config)
self.config_manager.load_config()
self.register_event(self.onPlayerMoveEvent, PlayerMoveEvent)
def onDisable(self):
self.config_manager.save_config()
def onPlayerMoveEvent(self, event):
if event.getFrom().getBlock() == event.getTo().getBlock():
return
to = event.getTo()
to_arr = [to.getBlockX(), to.getBlockY(), to.getBlockZ()]
for warp in self.config_manager.config['warpzones']:
if warp['area']['world'] == event.getPlayer().getLocation().getWorld().getName():
if self.is_in_range(to_arr, warp['area']['min'], warp['area']['max']): #Should probably do a rtree or something
to_loc = warp['to']['location']
event.getPlayer().teleport(Location(self.plugin.getServer().getWorld(warp['to']['world']), to_loc[0], to_loc[1], to_loc[2]))
def is_in_range(self, loc, mini, maxi):
return self.arr_gt(loc, mini) and self.arr_lt(loc, maxi)
def arr_gt(self, arr1, arr2):
for index in range(0, len(arr1)):
if not arr1[index] >= arr2[index]:
return False
return True
def arr_lt(self, arr1, arr2):
for index in range(0, len(arr1)):
if not arr1[index] <= (arr2[index]):
return False
return True
示例12: register_nick_and_username
def register_nick_and_username():
servconn().send_message(string.join([
"NICK",
ConfigManager.get("nick")], " "
))
servconn().send_message(string.join([
"USER",
ConfigManager.get("nick"),
socket.gethostname(),
ConfigManager.get("server"),
ConfigManager.get("nick")], " "
))
示例13: on_window_losefocus
def on_window_losefocus(self, window, event):
if self.slide_effect_running:
return
if ConfigManager.disable_losefocus_temporary:
return
if not ConfigManager.get_conf('losefocus-hiding'):
return
if self.get_property('visible'):
self.losefocus_time = GdkX11.x11_get_server_time(self.get_window())
if ConfigManager.get_conf('use-animation'):
self.slide_up()
self.unrealize()
self.hide()
示例14: onEnable
def onEnable(self):
self.config_manager = ConfigManager(
path.join(self.plugin.getDataFolder().getAbsolutePath(), "warpzones.yml"), default=self.default_config
)
self.config_manager.load_config()
self.register_event(self.onPlayerMoveEvent, PlayerMoveEvent)
示例15: __init__
def __init__ (self):
pygame.init()
pygame.key.set_repeat(10,10)
res = ConfigManager.get("resolution")
self.screen = pygame.display.set_mode(res, pygame.DOUBLEBUF)
self.ball = Ball()
self.space = Space(res)