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


Python Settings.set方法代码示例

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


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

示例1: ensure_stream_id

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
 def ensure_stream_id(self):
     try:
         self.sid = Settings.get(['torrents',self.hash,'sid'])
     except:
         chars = map(str,range(10)) + list('abcdef')
         sid = ''.join( [random.choice( chars ) for _ in range(5)] )
         Settings.set(['torrents',self.hash,'sid'], sid)
         self.sid = sid
开发者ID:kzahel,项目名称:ktorrent,代码行数:10,代码来源:torrent.py

示例2: set_config

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
def set_config(key, value):
    """
    Set configuration parameter.
    """
    try:
        Settings.set(key, value)
    except Exception as ex:
        raise click.ClickException('Some error while setting: %s' % ex)
开发者ID:mocsar,项目名称:csocso,代码行数:10,代码来源:csocso.py

示例3: save_metadata

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
    def save_metadata(self):
        torrent_meta = self.meta
        filename = torrent_meta['info']['name'] + '.torrent'
        key = self.hash
        #key = self.hash.upper()
        Settings.set(['torrents',key,'filename'],filename)

        fo = open( os.path.join(options.datapath, filename), 'w')
        fo.write( bencode.bencode(torrent_meta) )
        fo.close()
开发者ID:kzahel,项目名称:ktorrent,代码行数:12,代码来源:torrent.py

示例4: save_attributes

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
    def save_attributes(self):
        saveattrs = {}
        try:
            persisted = Settings.get(['torrents',self.hash,'attributes'])
        except KeyError:
            persisted = {}
        for k in self._attributes:

            if k in persisted and self._attributes[k] != persisted[k] or \
                    self._attributes[k] != self._default_attributes[k]:
                saveattrs[k] = self._attributes[k]
        if saveattrs:
            #logging.info('saved attributes %s' % saveattrs)
            path = ['torrents',self.hash,'attributes']
            Settings.set(path, saveattrs)
            saved = Settings.get(path)
开发者ID:kzahel,项目名称:ktorrent,代码行数:18,代码来源:torrent.py

示例5: Auth

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
class Auth(Debug):

	def __init__(self):
		self.authenticated = False
		self.settings = Settings()
		self.http = HTTP()
		self.table = DB().table('auth')

	@property
	def hasCredentials(self):
		
		if (self.settings.get('credentials.username') == "" or self.settings.get('credentials.password') == ""):
			return False
		else:
			return True

	@hasCredentials.setter
	def hasCredentials(self):
		
		self.username = ""
		self.password = ""

	@property
	def password(self):
		return self.settings.get('credentials.password')

	@password.setter
	def password(self, value):
		self.settings.set('credentials.password', value)

	@property
	def username(self):
		return self.settings.get('credentials.username')

	@username.setter
	def username(self, value):
		self.settings.set('credentials.username', value)

	def validate(self):
		pass
开发者ID:htpcsolutions,项目名称:script.module.htpc-solutions,代码行数:42,代码来源:auth.py

示例6: main

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
def main(port):
  # yaml形式の設定ファイルの読み込み
  settings = Settings("settings.yaml")

  # JANCODEテーブルがなかったら初期化
  if not settings.get("jancodes"):
    settings.set("jancodes", {})

  # カメラ画面の初期化
  camera = CameraWindow(settings)
  # カメラ画面の表示
  camera.start()
  # カメラ画面の更新処理を開始
  camera.event_set("run", "start")

  # ローカルホストのRFIDサーバへport番号を指定して接続
  client = RfidClient(port)
  # RFIDサーバの信号をCosmapperHandlerに投げるよう設定
  client.add_handler(CosmapperHandler(settings, camera))
  # RFIDサーバの信号をDresserHandlerに投げるよう設定
  client.add_handler(DresserHandler(settings, camera))
  # RFIDサーバの信号の処理を開始
  asyncore.loop()
开发者ID:MKnkgw,项目名称:MakeShareLog,代码行数:25,代码来源:main.py

示例7: Jenna

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
class Jenna(object):
    def __init__(self):
        GObject.threads_init()

        self.settings = Settings()
        self.api = GoogleMusic()

        builder = Gtk.Builder()
        builder.add_from_file('ui/main.glade')
        builder.connect_signals(self)

        self.loading_modal = builder.get_object('loadingModal')
        self.loading_modal_label = builder.get_object('loadingModalLabel')

        self.window = builder.get_object('mainWindow')

        self.notebook = builder.get_object('mainWindowNotebook')

        self.status_bar = builder.get_object('statusBar')
        self.status_bar_context_id = self.status_bar.get_context_id('search')

        self.preferences_dialog = builder.get_object('preferencesDialog')
        self.preferences_username_entry = builder.get_object('preferencesUsernameEntry')
        self.preferences_password_entry = builder.get_object('preferencesPasswordEntry')
        self.preferences_directory_chooser = builder.get_object('preferencesDirectoryChooser')

        self.search_entry = builder.get_object('searchEntry')

        self.track_list_store = builder.get_object('trackListStore')
        self.download_list_store = builder.get_object('downloadListStore')

        self.results_tree_view = builder.get_object('resultsTreeView')

        self.window.show_all()

    def on_preferences_dialog_show(self, dialog):
        self.preferences_username_entry.set_text(self.settings.get('username'))
        self.preferences_password_entry.set_text(self.settings.get('password'))
        self.preferences_directory_chooser.set_filename(self.settings.get('download_directory'))

    def on_preferences_ok_clicked(self, button):
        username = self.preferences_username_entry.get_text()
        password = self.preferences_password_entry.get_text()
        download_directory = self.preferences_directory_chooser.get_filename()

        self.settings.set('username', username)
        if password != self.settings.get('password'):
            self.settings.set('password', password.encode('base64'))
        self.settings.set('download_directory', download_directory)

        self.preferences_dialog.hide()

    def on_preferences_cancel_clicked(self, button):
        self.preferences_dialog.hide()

    def on_main_show(self, window):
        # check for login details
        # make async
        self.status_bar.push(self.status_bar_context_id, 'Logging into Google Music...')

        try:
            self.api.login(self.settings.get('username'), self.settings.get('password').decode('base64'))

            self.status_bar.push(self.status_bar_context_id, 'Logged in!')
        except Exception, ex:
            self.status_bar.push(self.status_bar_context_id, ex.message)
开发者ID:jonjomckay,项目名称:jenna,代码行数:68,代码来源:jenna.py

示例8: main

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
def main():
    parser = OptionParser(usage='Usage: login ......')
    parser.add_option("-f", "--file", dest="file_name",
                      help="file that you would like to parse", action="store")
    parser.add_option("-w", "--word", dest="word",
                      help="word that you would like to get its meaning", action="store")
    parser.add_option("-l", "--list", dest="list",
                      help="List words on wordbank", action="store_true")
    parser.add_option("-t", "--test", dest="test",
                      help="testing function", action="store")
    parser.add_option("-d", "--debug", dest="debug",
                      help="debug mode on!!", action="store_true")

    # parser.add_option("-p", "--password", dest="user_password", help="User password for log in", action="store")
    # parser.add_option("-s", "--serial-number", dest="serial_number", help="Project's serial number", action="store")
    # parser.add_option("-a", dest="job_type_long", help="Job for logn term",default=False, action="store_true")
    # parser.add_option("-w", dest="job_type_short", help="Job for short term",default=False, action="store_true")
    # parser.add_option("-q", dest="quiet", help="Make script more quiet",default=False, action="store_true")
    # parser.add_option("-i", "--sign-in", dest="sign_in", help="Sign in",default=False, action="store_true")
    # parser.add_option("-o", "--sign-out", dest="sign_out", help="Sign out",default=False, action="store_true")
    (options, args) = parser.parse_args()
    psettings = Settings()

    # set up settings.py!
    # mode settings
    if options.word is not None:
        psettings.set('mode', 'word')
        psettings.set('word', options.word)
    if options.file_name is not None:
        psettings.set('mode', 'file')
        psettings.set('file_name', options.file_name)
    if options.file_name is not None:
        psettings.set('mode', 'test')
        psettings.set('file_name', options.file_name)
    if options.list is not None:
        psettings.set('mode', 'list')
    if options.debug:
        psettings.set('debug', True)
        psettings.set('database', 'debug.db')


    # print("list all vocabulary")
    # print("file name\t", settings.file_name)
    # init

    directory = os.environ['HOME']+'/'+'.list_config'+'/'
    psettings.set('config_path', directory)
    if not os.path.exists(directory):
        os.makedirs(directory)

    my_dict = ydict()
    wordbank = WordBank()
    wordbank.db__init()
    wordbank.connect()


    # open file
    try:
        if psettings.get('mode') == 'interactive':
            try:
                while True:
                    query_word = input(psettings.get('name').__str__() + ">")
                    word = my_dict.search(query_word)
                    if word:
                        word.show_meaning()
                        if not wordbank.update(word.word):
                            wordbank.insert(word.word)
                        wordbank.commit()
                    else:
                        print("can't find %s" % query_word)
            except EOFError:
                print(psettings.get('msg_exit'))
            except:
                raise
        elif psettings.get('mode') == 'word':
            # print("search single word!")
            query_word = options.word
            word = my_dict.search(query_word)
            if word:
                word.show_meaning()
                if not wordbank.update(word.word):
                    wordbank.insert(word.word)
                wordbank.commit()
            else:
                print("can't find %s" % query_word)

        elif psettings.get('mode') == 'list':
            # print("search single word!")
            for word in wordbank.quer_for_all_word():
                print(word)
        elif psettings.get('mode') == 'file':
            f = open(settings.file_name)
            text = f.read()
            f.close()
            data = Data(text)
            data.do_word_list()

            for w in data.get_word_list():
                my_dict.search(w)
        elif psettings.get('mode') == 'test':
#.........这里部分代码省略.........
开发者ID:breeze101792,项目名称:list_vocabulary,代码行数:103,代码来源:main.py

示例9: App

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
class App(object):

    def __init__(self):
        # Define all game state variables
        self.welcome_screen = WelcomeScreen()
        self.game_screen = GameScreen()
        self.game_over_screen = GameOverScreen()
        self.difficulty = Difficulty(self.setOptions)

        self.points = 0
        self.done = False
        self.alert_loss = False

        self.settings = Settings()
        self.settings.set('hTime', 0.3)

        # Define all the Curses stuff
        curses.initscr()
        curses.start_color()

        curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK)
        curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)

        self.screen = curses.newwin(0, 0)
        self.screen.keypad(1)
        self.screen.nodelay(1)
        
        curses.noecho()
        curses.cbreak()
        curses.curs_set(0)

    def setOptions(self):
        self.settings.set('hTime', self.difficulty.getHTime())
        self.settings.set('obsWidth',10)
        self.settings.set('obsHoleHeigth', 7)
        self.settings.set('obsSpacing',15)

        self.game_screen.initGame(self.settings) 

    def deinit(self):
        self.screen.nodelay(0)
        self.screen.keypad(0)
        
        curses.nocbreak()
        curses.echo()
        curses.curs_set(1)
        curses.endwin()
        sys.exit(1)

    # Event Loop Functions

    def events(self):
        # Global Events
        key = self.screen.getch()
        if key == K_ESCAPE or key is K_Q:
            self.deinit()

        # State-depent events
        if not self.difficulty:
            self.difficulty.set(self.welcome_screen.events(key))
        else:
            self.game_screen.events(key)

    def update(self):

        if self.difficulty and not self.done:
            self.done, self.points = self.game_screen.update(self.screen, self.settings)

        if self.done:

            # Alert Loss Once
            if not self.alert_loss:
                curses.flash()
                curses.beep()
                curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK)
                self.alert_loss = True

    def render(self):
        self.screen.erase()

        # Render Current State
        if not self.difficulty:
            self.welcome_screen.screen(self.screen)
        else:
            self.game_screen.screen(self.screen, self.settings)
            if self.done:
                self.game_over_screen.screen(self.screen, self.points)

        # Refresh and Loop
        self.screen.refresh()
        time.sleep(self.settings.get('hTime'))

    def loop(self):
        while True:
            self.events()
            self.update()
            self.render()
开发者ID:thejsj,项目名称:Frank-y-Bird,代码行数:100,代码来源:main.py

示例10: GameMenu

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
class GameMenu():
	def __init__(self):
		print "Starting Menu"
		self.fail=False
		#Should read settings first
		self.get_settings()

		if self.settings.get('useJoystick') not in self.settings.false():
			self.joy=joystick.Joystick()
			if (self.joy.errors!=[]):
				for error in self.joy.errors:
					print error
					self.use_joystick=False
			else:
				self.use_joystick=True
		else:
			print "Ignoring any joystick due useJoystick in properties"
			self.use_joystick=False
			
		self.menuEntries = menuEntry.MenuEntry(self.num_entries_x,self.num_entries_y)
		self.menuEntries.settings(self.borders,self.gap_x,self.gap_y,self.menu_size_x,self.menu_size_y)
		self.readMenuFile()
		self.menuOutOfDate=False
		self.menuEntries.defined()
		if (self.settings.get('use_sound')):
			self.setupSounds()
		if (os.path.exists(self.settings.get('image_dir')+"/background.jpg")):
			self.background = pygame.image.load(os.path.join(self.settings.get('image_dir'),"background.jpg"))
			self.background = pygame.transform.scale(self.background,(self.screen_size_x,self.screen_size_y))
			self.use_background=True
		else:
			self.use_background = False
		self.init_filewatcher()
		iptool = netutils.ip_tool()
		self.ip = iptool.get_ip()
		print "Detected IP as", self.ip
		self.qrip = qr.QRImage('http://'+self.ip)
		self.qrip.prepare()
		pygame.init()
		font = pygame.font.Font(None, 20)
		self.iptext = fonts.textOutline(font,"To configure games go to "+self.ip+" or use the QR code.",[10,10,10],[255,255,255])

		
		# Set the height and width of the screen
		size=[self.screen_size_x,self.screen_size_y]
		#self.screen=pygame.display.set_mode(size,pygame.NOFRAME)
		if self.settings.get('fullscreen') in self.settings.true():
			self.screen=pygame.display.set_mode(size,pygame.FULLSCREEN|pygame.NOFRAME)
		else:
			self.screen=pygame.display.set_mode(size,pygame.NOFRAME)
		pygame.display.set_caption("GameMenu")
		# Used to manage how fast the screen updates
		self.clock=pygame.time.Clock()
		
	def get_settings(self):
		self.settings = Settings('local.properties')
		self.settings.print_data()
		self.screen_size_x = int(self.settings.get('screen_size_x'))
		self.screen_size_y = int(self.settings.get('screen_size_y'))
		self.tick = 1.0 / float(self.settings.get('frames_per_second'))
		
		self.num_entries_x = 4
		self.num_entries_y = 3
		self.num_pages = 2
		
		#Gap between menu entries
		self.gap_x = 20
		self.gap_y = 20
		
		self.borders = 100
		#self.border_top = 50
		#self.border_bottom = 50
		#self.border_left = 50
		#self.border_right = 50
		
		#Calculate the size of each menu item
		self.menu_size_x = ( self.screen_size_x - self.gap_x * (self.num_entries_x - 1) - 2*self.borders ) / self.num_entries_x
		self.menu_size_y = ( self.screen_size_y - self.gap_y * (self.num_entries_y - 1) - 2*self.borders ) / self.num_entries_y
		
		self.terminate=False
		
		
	def start(self):
		if (self.fail==True):
			print "Failed to start"
			return
		loop=True
		while (loop):
			if (self.menuOutOfDate==True):
				self.rereadMenuFile()
			self.draw()
			time.sleep(self.tick)
			if (self.use_joystick == True):
				joy_input = self.joy.get_input()
			else:
				#Want to use Keyboard instead.
				self.keyboard_loop()
				continue
			if (joy_input[1]==1):
				if (self.settings.get('use_sound')):
#.........这里部分代码省略.........
开发者ID:dean36963,项目名称:gameMenu,代码行数:103,代码来源:gameMenu.py

示例11: register_althash

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
 def register_althash(cls, torrent):
     althash = torrent.hash
     realhash = sha1(torrent.meta_info).hexdigest()
     Settings.set(['torrent_althashes',realhash], althash)
     logging.info('set torrent althash')
开发者ID:kzahel,项目名称:ktorrent,代码行数:7,代码来源:torrent.py

示例12: save_quick_resume

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
 def save_quick_resume(self):
     if self.bitmask:
         Settings.set(['torrents',self.hash,'bitmask'], self.encode_bitmask(self.bitmask))
开发者ID:kzahel,项目名称:ktorrent,代码行数:5,代码来源:torrent.py

示例13: Settings

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set [as 别名]
from settings import Settings


SETTINGS = Settings()

SETTINGS.set("center_server", "127.0.0.1:8080", autosave=False, override=False)
SETTINGS.set("center_server2", "127.0.0.1:8080", autosave=False, override=False)

SETTINGS.set("mainframe position", (100, 50), autosave=False, override=False)
SETTINGS.set("mainframe size", (800, 600), autosave=False, override=False)
SETTINGS.set("lang", "cn", autosave=False, override=False)

SETTINGS.save()
开发者ID:dalinhuang,项目名称:demodemo,代码行数:15,代码来源:__init__.py


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