本文整理汇总了Python中settings.Settings类的典型用法代码示例。如果您正苦于以下问题:Python Settings类的具体用法?Python Settings怎么用?Python Settings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Settings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
global screen
print("Nerd Tabu")
# Parse command line
parser = argparse.ArgumentParser()
parser.add_argument('quizfile', type=argparse.FileType('r'), help='Name of the quiz file')
parser.add_argument('teamA', nargs='?', metavar='teamname_A', default='Team A', help='Name of team A')
parser.add_argument('teamB', nargs='?', metavar='teamname_B', default='Team B', help='Name of team B')
parser.add_argument('-d', '--datadir', default='.', help='Resource directory')
parser.add_argument('-f', '--fullscreen', help='Run fullscreen', action='store_true')
args = parser.parse_args()
# Update settings
settings = Settings(args.quizfile, args.datadir)
settings.teams = [ args.teamA, args.teamB ]
theme = Theme(args.datadir)
# Initial game data
cards = settings.get_random_cards()
current_team = 0
# Main game loop
pygame.init()
if args.fullscreen:
# screen = pygame.display.set_mode(theme.screen_size, pygame.FULLSCREEN)
screen = pygame.display.set_mode(theme.screen_size, pygame.RESIZABLE | pygame.NOFRAME)
else:
screen = pygame.display.set_mode(theme.screen_size)
theme.load_data()
while len(cards)>0:
team_get_ready(theme, settings, current_team)
play_round(theme, settings, current_team, cards)
current_team = (current_team + 1) % len(settings.teams)
show_final_scores(theme, settings)
pygame.quit()
开发者ID:Skyr,项目名称:nerdtabu,代码行数:32,代码来源:nerdtabu.py
示例2: show
def show(self):
log("SonosArtistSlideshow: About to show window")
# First show the window
SonosControllerWindow.show(self)
# Work out how many lines there are on the screen to show lyrics
if Settings.isLyricsInfoLayout():
lyricControl = self.getControl(SonosArtistSlideshow.LYRICS)
if lyricControl is not None:
listitem = xbmcgui.ListItem()
while xbmc.getInfoLabel('Container(%s).NumPages' % SonosArtistSlideshow.LYRICS) != '2':
lyricControl.addItem(listitem)
xbmc.sleep(10)
self.lyricListLinesCount = lyricControl.size() - 1
lyricControl.reset()
self.windowId = xbmcgui.getCurrentWindowId()
log("SonosArtistSlideshow: After show window %s" % self.windowId)
# Set the sonos icon
if not Settings.hideSonosLogo():
xbmcgui.Window(self.windowId).setProperty('SonosAddonIcon', __icon__)
# Set option to make the artist slideshow full screen
if Settings.fullScreenArtistSlideshow():
xbmcgui.Window(self.windowId).setProperty('SonosAddonSlideshowFullscreen', "true")
# Now make sure that Artist Slideshow is running
self.athread = threading.Thread(target=self.runArtistSlideshow)
self.athread.setDaemon(True)
self.athread.start()
log("SonosArtistSlideshow: ArtistSlideShow thread started")
开发者ID:noba3,项目名称:KoTos,代码行数:33,代码来源:default.py
示例3: get_db
def get_db():
config = Settings()
return pymysql.connect(host=config.setting("dbhost"),
user=config.setting("dbuser"),
passwd=config.setting("dbpassword"),
db=config.setting("dbbase"),
charset="utf8")
开发者ID:paladin8818,项目名称:RTSSystem,代码行数:7,代码来源:database.py
示例4: check
def check(self):
# If we have found the correct user, then we need to ensure we are
# in the valid time duration and have not exceeded the limit
if not self.isEnabled:
return True
# Check for the case where we didn't get the user ID - this means we are
# already shutting down
if self.userId in [None, ""]:
return False
log("UserPinControl: Performing check for user %s" % self.userId)
# First check that the current time is within the allowed boundaries
localTime = time.localtime()
currentTime = (localTime.tm_hour * 60) + localTime.tm_min
if self.allowedStartTime > currentTime or self.allowedEndTime < currentTime:
log("UserPinControl: User not allowed access until %d to %d currently %d" % (self.allowedStartTime, self.allowedEndTime, currentTime))
self.shutdown(32130)
return False
# Check if the screensaver is running, if so we need to make sure we do not
# class that as time used by the user
if xbmc.getCondVisibility("System.ScreenSaverActive"):
if self.screensaverStart < 1:
self.screensaverStart = currentTime
else:
# Not the screensaver, check to see if this is the first check
# after the screensaver stopped
if self.screensaverStart > 0:
screensaverDuration = currentTime - self.screensaverStart
self.screensaverStart = 0
log("UserPinControl: Updating duration for screensaver, %d minutes" % screensaverDuration)
# Now we roll the time forward that we started viewing so that
# we are not counting the screensaver
self.startedViewing = self.startedViewing + screensaverDuration
# Check to see if we need to update the record for how long the user has already been viewing
viewingLimit = Settings.getUserViewingLimit(self.userId)
self.usedViewingLimit = currentTime - self.startedViewing
log("UserPinControl: Time used by user is %d" % self.usedViewingLimit)
# Update the settings record for how much this user has viewed so far
Settings.setUserViewingUsedTime(self.userId, self.usedViewingLimit)
# Now check to see if the user has exceeded their limit
if self.usedViewingLimit >= viewingLimit:
self.shutdown(32133)
return False
# Check if we need to warn the user that the time is running out
warningTime = Settings.getWarnExpiringTime()
if (not self.warningDisplayed) and ((self.usedViewingLimit + warningTime) >= viewingLimit):
self.warningDisplayed = True
# Calculate the time left
remainingTime = viewingLimit - self.usedViewingLimit
msg = "%d %s" % (remainingTime, __addon__.getLocalizedString(32134))
xbmcgui.Dialog().notification(__addon__.getLocalizedString(32001).encode('utf-8'), msg, __icon__, 3000, False)
return True
开发者ID:MrMC,项目名称:script.pinsentry,代码行数:60,代码来源:service.py
示例5: check_rpmlint_errors
def check_rpmlint_errors(out, log):
""" Check the rpmlint output, return(ok, errmsg)
If ok, output is OK and there is 0 warnings/errors
If not ok, and errmsg!= None there is system errors,
reflected in errmsg. If not ok and msg == None parsing
is ok but there are warnings/errors"""
problems = re.compile('(\d+)\serrors\,\s(\d+)\swarnings')
lines = out.split('\n')[:-1]
err_lines = filter( lambda l: l.lower().find('error') != -1,
lines)
if len(err_lines) == 0:
Settings.get_logger().debug('Cannot parse rpmlint output: '
+ out)
return False, 'Cannot parse rpmlint output:'
res = problems.search(err_lines[-1])
if res and len(res.groups()) == 2:
errors, warnings = res.groups()
if errors == '0' and warnings == '0':
return True, None
else:
return False, None
else:
log.debug('Cannot parse rpmlint output: ' + out )
return False, 'Cannot parse rpmlint output:'
开发者ID:hadrons123,项目名称:FedoraReview,代码行数:26,代码来源:helpers.py
示例6: main
def main():
#Set this to true if you want to create a personal database
testdatabase = False
#Set this due to how large you want your testdatabase
count = 10
#creating a settings to be used with run
cuts = environment.generateCuts()
settings = Settings(cuts)
environment.setSettings(settings)
settings.setMethod("expanded")
globalSettings = GlobalSettings()
environment.setGlobalSettings(globalSettings)
db = Database(globalSettings)
#making a testdatabase if the varible is set
if testdatabase == True:
currentDBCount= m.Painting.select().count()
count = count - currentDBCount
if count > 0:
db.setCount(count)
db.constructDatabase()
else:
db.constructDatabase()
run = m.createNewRun(settings)
paintings = m.Painting.select(m.Painting.q.form=="painting")
for painting in paintings:
if os.path.isfile(painting.filepath):
try:
paintingContainer = Painting(painting)
print "working on"
print painting.filepath
paintingContainer.setResults(paintingAnalyzer.analyze(paintingContainer,settings))
m.saveResults(run.id,paintingContainer)
except:
pass
开发者ID:thorlund,项目名称:gyldnesnit,代码行数:34,代码来源:start.py
示例7: listpaths
def listpaths(pkg_filename):
''' Return lists of files and dirs in local pkg. '''
cmd = ['rpm', '-ql', '--dump', '-p', pkg_filename]
Settings.get_logger().debug("Running: " + ' '.join(cmd))
try:
rpm = subprocess.Popen(cmd, stdout=subprocess.PIPE)
except OSError:
Settings.get_logger().warning("Cannot run " + " ".join(cmd))
return []
files = []
dirs = []
while True:
try:
line = rpm.stdout.next().strip()
except StopIteration:
return dirs, files
try:
path, mode = line.rsplit(None, 10)[0:5:4]
except ValueError:
# E. g., when given '(contains no files)'
continue
mode = int(mode, 8)
if mode & 040000:
dirs.append(path)
else:
files.append(path)
开发者ID:timlau,项目名称:FedoraReview,代码行数:27,代码来源:deps.py
示例8: __init__
def __init__(self, rawPath, pathList=None, videotitle=None, debug_logging_enabled=True, audioOnly=False):
self.debug_logging_enabled = debug_logging_enabled
self.forceShuffle = False
self.doNotShuffle = False
self.audioOnly = audioOnly
self.rawPath = rawPath
if rawPath in [None, ""]:
self.clear()
else:
# Check for the case where there is a custom path set so we need to use
# the custom location rather than the rawPath
if Settings.isCustomPathEnabled() and (videotitle not in [None, ""]):
customRoot = Settings.getCustomPath()
# Make sure that the path passed in has not already been converted
if customRoot not in self.rawPath:
self.rawPath = os_path_join(customRoot, normalize_string(videotitle))
log("ThemeFiles: Setting custom path to %s" % self.rawPath, self.debug_logging_enabled)
if (pathList is not None) and (len(pathList) > 0):
self.themeFiles = []
for aPath in pathList:
subThemeList = self._generateThemeFilelistWithDirs(aPath)
# add these files to the existing list
self.themeFiles = self._mergeThemeLists(self.themeFiles, subThemeList)
# If we were given a list, then we should shuffle the themes
# as we don't always want the first path playing first
self.forceShuffle = True
else:
self.themeFiles = self._generateThemeFilelistWithDirs(self.rawPath)
# Check if we need to handle the ordering for video themes
if not audioOnly:
self.doNotShuffle = self._filterForVideoThemesRule()
self.forceShuffle = False
开发者ID:kodibrasil,项目名称:KodiBrasil,代码行数:34,代码来源:themeFinder.py
示例9: _moveToThemeFolder
def _moveToThemeFolder(self, directory):
log("moveToThemeFolder: path = %s" % directory)
# Handle the case where we have a disk image
if (os_path_split(directory)[1] == 'VIDEO_TS') or (os_path_split(directory)[1] == 'BDMV'):
directory = os_path_split(directory)[0]
dirs, files = list_dir(directory)
for aFile in files:
m = re.search(Settings.getThemeFileRegEx(directory), aFile, re.IGNORECASE)
if m:
srcpath = os_path_join(directory, aFile)
log("fetchAllMissingThemes: Found match: %s" % srcpath)
targetpath = os_path_join(directory, Settings.getThemeDirectory())
# Make sure the theme directory exists
if not dir_exists(targetpath):
try:
xbmcvfs.mkdir(targetpath)
except:
log("fetchAllMissingThemes: Failed to create directory: %s" % targetpath, True, xbmc.LOGERROR)
break
else:
log("moveToThemeFolder: directory already exists %s" % targetpath)
# Add the filename to the path
targetpath = os_path_join(targetpath, aFile)
if not xbmcvfs.rename(srcpath, targetpath):
log("moveToThemeFolder: Failed to move file from %s to %s" % (srcpath, targetpath))
开发者ID:angelblue05,项目名称:script.tvtunes,代码行数:27,代码来源:plugin.py
示例10: InfoDialog
class InfoDialog(QDialog, Ui_Info):
def __init__(self):
QDialog.__init__(self)
self.setupUi(self)
self.settings = Settings()
self.permit_close = False
self.ok.clicked.connect(self.accepted)
self.wait = 10
self.stimer = QTimer
self.ok.setText(unicode(self.wait))
self.stimer.singleShot(1000, self.updateTimer)
def updateTimer(self):
self.wait -= 1
self.ok.setText(unicode(self.wait))
if self.wait > 0:
self.stimer.singleShot(1000, self.updateTimer)
else:
self.ok.setEnabled(True)
self.ok.setText("OK")
def accepted(self):
if self.understood.isChecked():
self.permit_close = True
self.settings.setValue('info_accepted', True)
self.close()
def closeEvent(self, evnt):
if self.permit_close:
super(InfoDialog, self).closeEvent(evnt)
else:
evnt.ignore()
开发者ID:AlexSatrapa,项目名称:EliteOCR,代码行数:33,代码来源:info.py
示例11: MapFrame
class MapFrame(wx.Frame):
def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name="MapFrame"):
super(MapFrame, self).__init__(parent, id, title, pos,
(MAX_COL*CELL_X, MAX_ROW*CELL_Y+20),
style, name)
self.SetIcon(wx.Icon("img/icon.png", wx.BITMAP_TYPE_PNG))
self.settings = Settings()
global board, colors, player, tiled
board = self.settings.load_map('config/map1.txt')
colors = self.settings.load_colors()
tiled = Tiled()
player = Player()
self.panel = MapPanel(self)
self.InitUI()
#~ ag = wx.animate.GIFAnimationCtrl(self.panel, -1, self.player.src,
#~ pos=(10, 10))
#~ ag.GetPlayer().UseBackgroundColour(True)
#~ ag.Play()
self.Centre()
self.Show(True)
def InitUI(self):
menubar = wx.MenuBar()
fileMenu = wx.Menu()
menubar.Append(fileMenu, '&File')
self.SetMenuBar(menubar)
开发者ID:Pent00,项目名称:rpg-map,代码行数:34,代码来源:map.py
示例12: checkEnding
def checkEnding(self):
if self.isPlayingAudio() and (self.startTime > 0):
# Get the current time
currTime = int(time.time())
# Time in minutes to play for
durationLimit = Settings.getPlayDurationLimit()
if durationLimit > 0:
expectedEndTime = self.startTime + (60 * durationLimit)
if currTime > expectedEndTime:
self.endPlaying(slowFade=True)
return
# Check for the case where only a given amount of time of the track will be played
# Only skip forward if there is a track left to play - otherwise just keep
# playing the last track
if (self.playlistSize > 1) and (self.remainingTracks != 0):
trackLimit = Settings.getTrackLengthLimit()
if trackLimit > 0:
if currTime > self.trackEndTime:
log("Player: Skipping to next track after %s" % self.getPlayingFile())
self.playnext()
if self.remainingTracks != -1:
self.remainingTracks = self.remainingTracks - 1
self._setNextSkipTrackTime(currTime)
开发者ID:nspierbundel,项目名称:OpenELEC.tv,代码行数:26,代码来源:tvtunes_backend.py
示例13: StatusBar
class StatusBar():
def __init__(self, window):
self.window = window
self.settings = Settings()
def update(self):
if ProcessCache.empty():
return self.erase()
status_bar_tasks = self.settings.get('status_bar_tasks', False)
if status_bar_tasks:
task_names = set([process.get_task_name() for process in ProcessCache.get()])
if status_bar_tasks != True:
if not isinstance(status_bar_tasks, list):
status_bar_tasks = [status_bar_tasks]
task_names = task_names.intersection(set(status_bar_tasks))
if task_names:
defer_sync(lambda: self.set(', '.join(task_names)))
def set(self, text):
text_format = self.settings.get('status_bar_format', '{task_name}')
status = text_format.format(task_name=text)
self.window.active_view().set_status(Settings.PACKAGE_NAME, status)
def erase(self):
self.window.active_view().erase_status(Settings.PACKAGE_NAME)
开发者ID:NicoSantangelo,项目名称:sublime-gulp,代码行数:30,代码来源:status_bar.py
示例14: _doesThemeExist
def _doesThemeExist(self, directory):
log("doesThemeExist: Checking directory: %s" % directory)
# Check for custom theme directory
if Settings.isThemeDirEnabled():
themeDir = os_path_join(directory, Settings.getThemeDirectory())
# Check if this directory exists
if not dir_exists(themeDir):
workingPath = directory
# If the path currently ends in the directory separator
# then we need to clear an extra one
if (workingPath[-1] == os.sep) or (workingPath[-1] == os.altsep):
workingPath = workingPath[:-1]
# If not check to see if we have a DVD VOB
if (os_path_split(workingPath)[1] == 'VIDEO_TS') or (os_path_split(workingPath)[1] == 'BDMV'):
# Check the parent of the DVD Dir
themeDir = os_path_split(workingPath)[0]
themeDir = os_path_join(themeDir, Settings.getThemeDirectory())
directory = themeDir
# check if the directory exists before searching
if dir_exists(directory):
# Generate the regex
themeFileRegEx = Settings.getThemeFileRegEx(audioOnly=True)
dirs, files = list_dir(directory)
for aFile in files:
m = re.search(themeFileRegEx, aFile, re.IGNORECASE)
if m:
log("doesThemeExist: Found match: " + aFile)
return True
return False
开发者ID:angelblue05,项目名称:script.tvtunes,代码行数:31,代码来源:scraper.py
示例15: _do_run
def _do_run(self, outfile=None):
''' Initiate, download url:s, run checks a write report. '''
Settings.init()
make_report = True
if Settings.list_checks:
self._list_checks()
make_report = False
elif Settings.list_flags:
self._list_flags()
make_report = False
elif Settings.version:
self._print_version()
make_report = False
elif Settings.list_plugins:
self._list_plugins()
make_report = False
elif Settings.url:
self.log.info("Processing bug on url: " + Settings.url)
self.bug = UrlBug(Settings.url)
elif Settings.bug:
self.log.info("Processing bugzilla bug: " + Settings.bug)
self.bug = BugzillaBug(Settings.bug)
elif Settings.name:
self.log.info("Processing local files: " + Settings.name)
self.bug = NameBug(Settings.name)
if make_report:
if not Mock.is_available() and not Settings.prebuilt:
raise ReviewError("Mock unavailable, --prebuilt must be used.")
self._do_report(outfile)
开发者ID:timlau,项目名称:FedoraReview,代码行数:29,代码来源:review_helper.py
示例16: __init__
def __init__(self, **args):
"""Create the default settings."""
Settings.__init__(self, 'StyleSheet', setnsmode='stylesheet', **args)
self.pixmap = 'settings_stylesheet'
for subset in self.registeredsettings:
self.add( subset() )
开发者ID:JoonyLi,项目名称:veusz,代码行数:7,代码来源:stylesheet.py
示例17: _do_report
def _do_report(self, outfile=None):
''' Create a review report'''
clock = time.time()
self.log.info('Getting .spec and .srpm Urls from : '
+ self.bug.get_location())
Settings.dump()
if not self.bug.find_urls():
raise self.HelperError('Cannot find .spec or .srpm URL(s)')
self.log.debug("find_urls completed: %.3f"
% (time.time() - clock))
clock = time.time()
if not ReviewDirs.is_inited:
wd = self.bug.get_dirname()
ReviewDirs.workdir_setup(wd)
if Mock.is_available():
Mock.init()
if not self.bug.download_files():
raise self.HelperError('Cannot download .spec and .srpm')
self.log.debug("Url download completed: %.3f" % (time.time() - clock))
Settings.name = self.bug.get_name()
self._run_checks(self.bug.spec_file, self.bug.srpm_file, outfile)
开发者ID:timlau,项目名称:FedoraReview,代码行数:25,代码来源:review_helper.py
示例18: Context
class Context(object):
def __init__(self, root_dir):
self.bus = Bus()
self.settings = Settings(root_dir=root_dir)
def load_settings(self, config_path):
self.settings.load(config_path)
开发者ID:MaxMorais,项目名称:skink,代码行数:7,代码来源:context.py
示例19: setUserPin
def setUserPin(pinId):
# Prompt the user for the pin
numberpad = NumberPad.createNumberPad(32106)
numberpad.doModal()
# Get the code that the user entered
enteredPin = numberpad.getPin()
del numberpad
# Check to ensure the user has either set no password or one the correct length
if (len(enteredPin) > 0) and (Settings.getPinLength() > len(enteredPin)):
log("SetPin: Incorrect length pin entered, expecting %d digits" % Settings.getPinLength())
xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32109).encode('utf-8'))
elif Settings.checkUserPinClash(enteredPin, pinId):
# This pin clashes with an existing pin
log("SetPin: Entered pin clashes with an existing pin")
xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32112).encode('utf-8'))
else:
# Now double check the value the user entered
numberpad = NumberPad.createNumberPad(32107)
numberpad.doModal()
# Get the code that the user entered
enteredPin2 = numberpad.getPin()
del numberpad
if enteredPin == enteredPin2:
Settings.setUserPinValue(enteredPin, pinId)
else:
log("SetPin: Pin entry different, first: %s, second %s" % (enteredPin, enteredPin2))
xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32108).encode('utf-8'))
开发者ID:Stevie-Bs,项目名称:repository.xvbmc,代码行数:31,代码来源:setpin.py
示例20: get_vk
def get_vk():
settings = Settings()
users = settings.getUsers()
selected_user = UserPrompt().prompt_user("Select user:", users)
settings.setUser(selected_user)
vk = vkutils.VK(settings)
return vk
开发者ID:maks-skynet,项目名称:zombot-1,代码行数:7,代码来源:main.py
注:本文中的settings.Settings类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论