本文整理汇总了Python中Settings.Settings.get方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.get方法的具体用法?Python Settings.get怎么用?Python Settings.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings.Settings
的用法示例。
在下文中一共展示了Settings.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def __init__(self):
self._conn = Connection(FileStorage(Settings.get("projectsDataPath")))
self._data = self._conn.get_root()
if not len(self._data.keys()):
self._data["Default"] = PersistentDict(autocomplete=PersistentDict())
self.sync()
示例2: leftSeconds
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def leftSeconds(self):
"""Return time left to work"""
res = Settings.get("workDayLength") - self.spentSeconds
if res < 0:
return 0
else:
return res
示例3: checkForUpdate
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def checkForUpdate(self):
update = 0
settings = Settings(os.getcwd() + '/' +"wlc_load.db") # i coded myself into a corner
while True:
if update < settings.get("lastUpdate"):
#send data to client
self.broadCast_Msg("Hello....smells like success")
time.sleep(2)
示例4: initControls
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def initControls(self):
"""Init basic controls"""
self.outputArea.setString_("")
self.tasks = Tasks()
if Settings.get("showWorkTill"):
self.workTillBox.setHidden_(False)
else:
self.workTillBox.setHidden_(True)
self.pbtnProject.removeAllItems()
self.pbtnProject.addItemsWithTitles_(Projects.get())
self.pbtnProject.selectItemWithTitle_(Settings.get("selectedProject"))
self.projectChange_(None)
self.fillTasks()
self.scrollToEnd()
示例5: formatTaskString
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def formatTaskString(date, task, projectName, spentSeconds, taskType):
"""Format task string"""
if taskType == "work":
color = NSColor.blackColor()
elif taskType == "slack":
color = NSColor.grayColor()
else:
color = NSColor.colorWithCalibratedRed_green_blue_alpha_(.72,.72,.72, 1)
if spentSeconds is None: # Start of the day
taskString = "Your working day started on %s \n" % date.strftime("%c")
return taskString, color
else:
dtStr = ""
if Settings.get("showDateTime"):
dtStr = " " + date.strftime(str(Settings.get("logDateTimeFormat")))
project = ""
if projectName != "" and projectName != "Default" and taskType == "work":
project = "%s %s " % (projectName, Settings.get("projectSeparator"))
return "%s%s >> %s%s \n" % (secToTimeStr(spentSeconds), dtStr, project, task), color
示例6: btnDonePress_
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def btnDonePress_(self, sender):
"""On done button press"""
if self.tasks.dayStarted():
if self.cbxInput.stringValue().strip():
taskName = self.cbxInput.stringValue()
self.appendTask(*fh.formatTaskString(*self.tasks.add(taskName, self.pbtnProject.titleOfSelectedItem())))
self.readCounters()
self.cbxInput.setStringValue_("")
self.scrollToEnd()
if Tasks.taskType(taskName) == "work":
Projects.addAutocomplete(self.pbtnProject.titleOfSelectedItem(), taskName)
else:
SlackingAutocompletes.add(taskName)
self.cbxInput.addItemWithObjectValue_(taskName)
else:
if Settings.get("showHelpMessageOnStart"):
self.showStartHelpMessage()
taskName = Settings.get("startPlaceholder")
self.appendTask(*fh.formatTaskString(*self.tasks.add(taskName)))
self.initDoneButton()
示例7: initVlaues
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def initVlaues(self):
self.stprWorkHours.setIntValue_(fh.secToHours(Settings.get("workDayLength")))
self.edtWorkHours.setIntValue_(self.stprWorkHours.intValue())
self.stprNotificationTime.setIntValue_(Settings.get("notificationTime"))
self.edtNotificationTime.setIntValue_(self.stprNotificationTime.intValue())
self.stprNotificationRepeatTime.setIntValue_(Settings.get("notificationRepeatTime"))
self.edtNotificationRepeatTime.setIntValue_(self.stprNotificationRepeatTime.intValue())
workEndTime = datetime.datetime.strptime(Settings.get("workEndTime"), "%H:%M").time()
someDate = datetime.datetime.combine(datetime.datetime.now(), workEndTime)
self.dpkrWorkStarts.setDateValue_(fh.datetimeToNSDate(someDate))
self.edtLogEditCommand.setStringValue_(Settings.get("logEditCommand"))
self.chbShowWorkTill.setState_(1 if Settings.get("showWorkTill") else 0)
self.chbShowDateTime.setState_(1 if Settings.get("showDateTime") else 0)
self.chbShowNotification.setState_(1 if Settings.get("showNotification") else 0)
self.chbSoundOnNotification.setState_(1 if Settings.get("soundOnNotification") else 0)
self.edtDateTimeFormat.setStringValue_(Settings.get("logDateTimeFormat"))
self.edtDateTimeFormat.setEnabled_(self.chbShowDateTime.state())
self.showNotification_(self)
示例8: SettingsTest
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
class SettingsTest(unittest.TestCase) :
SETTINGS_PATH = os.path.expanduser('settingstest.xml')
@classmethod
def setUpClass(self) :
Settings.loadSettings(self.SETTINGS_PATH)
self.settings = Settings("test")
def test_string(self) :
defaulttest = self.settings.get('defaulttest', 'defaulttest')
self.settings.set('gettest', 'gettest')
gettest2 = self.settings.get('gettest', 'defaulttest')
self.assertEquals(defaulttest, 'defaulttest')
self.assertEquals(gettest2, 'gettest')
def test_int(self) :
gettest1 = self.settings.get('gettest', 4)
self.settings.set('gettest', 1)
gettest2 = self.settings.get('gettest', 4)
self.assertEquals(gettest1, 4)
self.assertEquals(gettest2, 1)
def test_bool(self) :
gettest1 = self.settings.get('gettest', False)
self.settings.set('gettest2', True)
self.settings.set('gettest3', False)
gettest2 = self.settings.get('gettest2', False)
gettest3 = self.settings.get('gettest3', False)
self.assertEquals(gettest1, False)
self.assertEquals(gettest2, True)
self.assertEquals(gettest3, False)
def test_write(self) :
self.settings.write()
self.assertTrue(os.path.exists(self.SETTINGS_PATH))
@classmethod
def tearDownClass(self) :
os.remove(self.SETTINGS_PATH)
示例9: __init__
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def __init__(self, argv):
self.loaded = False
self.config = wx.Config("OSW-IDE", style = wx.CONFIG_USE_LOCAL_FILE)
self.path = os.getcwd()
# All functions here will be called upon exit
self.onExit = [Settings.saveConfig]
Settings()
# All defined platforms
self.platforms = self.getPlatformsFromMakefile()
self.platformOnly = None
self.excludedPlatforms = list()
self.activePlatform = self.platforms.index("telosb")
# Flag indicates that next thread's output shouldn't trigger
# force switching to info area tab.
self.supressTabSwitching = False
self.targets = [None]
self.targetType = "USB"
self.activeThreads = {}
self.onExit.append(self.killAllThreads)
if LOG_TO_FILE:
path = os.getcwd()
os.chdir(self.path)
self.logFile = open(LOG_FILE_NAME, "a")
os.chdir(path)
self.onExit.append(self.logFile.close)
# this is path from /osw/tools/IDE
self.pathToMansos = os.path.join(self.path, "../..")
# Try to get system default font
#font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
#self.fontName = font.GetFaceName()
#if self.fontName != "":
# print "Using system default font: {}".format(self.fontName)
#else:
self.fontName = "Courier New"
# print "Can't find system default font, defaulting to {}".\
# format(self.fontName)
self.listenModules = list()
self.editors = list()
icon = os.path.normpath('../../doc/osw-32x32.ico')
### Module initializations
# Visual objects here can be used in forms only after they have been re-parented
# using their Reparent() function, else they won't be visible!
self.emptyFrame = wx.Frame(None)
# Defines seal syntax
self.sealSyntax = SealSyntax(self)
# Init translation module
Translater(self)
# Init output_tools
#self.outputTools = OutputTools(self.emptyFrame, self)
# Init outputArea for info, 1st tab
self.infoArea = OutputArea(self.emptyFrame, self, 0)
self.printInfo = self.infoArea.printLine
self.clearInfoArea = self.infoArea.clear
# Init blockly handler
if os.path.exists(os.path.join(self.path, Settings.get("blockly_location"))):
self.blockly = Blockly(self.emptyFrame, self)
self.foundBlockly = True
else:
print "Warning: No SEAL-Blockly found!"
self.foundBlockly = False
# Init seal parser
self.sealParser = seal_parser.SealParser("msp430", self.printInfo, False, True)
# Init tab manager
self.tabManager = TabManager(self.emptyFrame, self)
# Init listenModule
self.listenModules.append(ListenModule(self.emptyFrame, self))
self.editPanel = ScrolledPanel(self.emptyFrame)
self.editWindow = EditStatement(self.editPanel, self)
self.frame = Frame(None, "OSW IDE", (0, 0), (0, 0), self)
#.........这里部分代码省略.........
示例10: workEndTime
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def workEndTime():
return datetime.datetime.strptime(Settings.get("workEndTime"), "%H:%M").time()
示例11: awakeFromNib
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def awakeFromNib(self):
def onGrowlClick():
self.applicationRef.unhide()
self.cbxInput.becomeFirstResponder()
self.notification = Notification(onGrowlClick)
self.initControls()
self.initWindowStates()
self.readCounters()
self._timer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(Settings.get("timerInterval"),
self, self.timerFunction, None, True)
示例12: __init__
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
class VideoManager :
def __init__(self) :
self.videos = dict()
self.services = dict()
self.locSettings = Settings('location')
self.storageSettings = Settings('storage')
if not os.path.exists(self.thumbnailDir()) :
os.mkdir(self.thumbnailDir())
if not os.path.exists(self.videoDir()) :
os.mkdir(self.videoDir())
def cleanup(self) :
videotimelimit = self.storageSettings.get('videotimelimit', 7)
for video in self.videos.values() :
filepath = video.filename()
if os.path.exists(filepath) :
modifydate = datetime.fromtimestamp(os.stat(filepath).st_mtime)
timeSinceModify = datetime.now() - modifydate
if timeSinceModify.days >= videotimelimit :
os.remove(filepath)
thumbnailpath = video.thumbnail()
if thumbnailpath and os.path.exists(thumbnailpath) :
accessdate = datetime.fromtimestamp(os.stat(thumbnailpath).st_atime)
timeSinceAccess = datetime.now() - accessdate
if timeSinceAccess.days >= 7 :
os.remove(thumbnailpath)
def addService(self, name, service) :
self.services[name] = service
def thumbnailDir(self) :
return DATA_DIR + 'thumbnails/'
def videoDir(self) :
return self.locSettings.get('videos', DATA_DIR + 'videos/')
def addVideo(self, video) :
self.videos[video.url()] = video
def userPlaylist(self, name) :
playlist = CompositeVideoPlaylist()
for service in self.services.values() :
playlist.addPlaylist(service.userPlaylist(name))
return playlist
def subscriptionPlaylist(self) :
playlist = CompositeVideoPlaylist()
for service in self.services.values() :
playlist.addPlaylist(service.subscriptionPlaylist())
return playlist
def playlist(self, id) :
return self.services.values()[0].playlist(id)
示例13: writeTask
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def writeTask(self, data, task, projectName, firstToday=False):
if firstToday:
task = Settings.get("startPlaceholder")
projectName = None
self._driver.writeTask(data, task, projectName)
示例14: Critter
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
class Critter(object):
"""The Critter - the base for other critters.
All other critters written in python should derive from this class.
Attributes:
mBehavior: The behavior.
mGracefulShutdown: Defines whether the graceful shutdown was not started.
mLogger: The logger.
mPostOffice: The post office that handles all communication.
mRites: The dictionary of rites.
mSettings: The settings read from the manifest.
mCrittnick: The crittnick.
"""
# TODO: Remove aType.
def __init__(self, aArgv):
self.mSettings = Settings(aArgv[3] + aArgv[4] + ":" + aArgv[5], aArgv[6] + aArgv[7] + ":" + aArgv[8])
# Configuring the logger.
self.mLogger = logging.getLogger(aArgv[1])
self.mLogger.propagate = False
handler = logging.FileHandler("/tmp/" + aArgv[1] + ".log")
formatter = logging.Formatter("[%(asctime)s][%(threadName)28s][%(levelname)8s] - %(message)s")
handler.setFormatter(formatter)
self.mLogger.addHandler(handler)
self.mLogger.setLevel(self.mSettings.get("logging", "level"))
self.mCrittnick = aArgv[1]
# TODO: Implement sequential starting (in order of dependencies).
# This is a matter of performing full startup procedure properly.
self.mRites = {}
self.mLogger.debug("Initializing the post office.")
self.mPostOffice = PostOffice(self)
self.mGracefulShutdown = False
# FIXME: Rites should be started in appropriate sequence, according to dependencies.
# TODO: Remove the hardcoded number of services.
rites = [Rites.RiteCommon.REGISTRY, Rites.RiteCommon.HEARTBEAT] + [aArgv[9]]
for rite in rites:
self.mLogger.info("Spawning the %s rite." % rite)
if rite in self.mRites:
# TODO: For now this is ok. If e.g. rites are started recursively, then this will not work!
self.mLogger.critical("Rite %s has been already started." % rite)
sys.exit(1)
else:
self.mRites[rite] = createRite(self, rite)
for rite in rites:
self.mLogger.info("Starting the %s rite." % rite)
self.mRites[rite].start()
# Spawning the behavior.
self.mLogger.debug("Spawning the behavior.")
self.mBehavior = CritterBehavior(self)
self.mBehavior.setDaemon(True)
self.mBehavior.start()
self.mLogger.debug("Starting the post office.")
self.mPostOffice.start()
def run(self):
"""Runs the critter."""
self.mLogger.debug("Critter is alive and kicking. And starts to run...")
while not self.mGracefulShutdown:
self.mLogger.debug("Sleeping for a heartbeat.")
time.sleep(self.mSettings.get("heartbeat", "period"))
self.mLogger.debug("Goodbye, cruel world...")
def getPostOffice(self):
"""Gets the post office that handles all communication.
Returns:
The post office that handles all communication.
"""
return self.mPostOffice
def getSettings(self):
"""Gets the critter's settings (read from the manifest).
Returns:
The critter's settings (read from the manifest).
"""
return self.mSettings
示例15: __init__
# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import get [as 别名]
def __init__(self, parent, row, videoHandler) :
QObject.__init__(self, parent)
if self.pixmaps == None :
self.pixmaps = dict()
self.pixmaps['preloadEnabled'] = QPixmap(IMAGE_DIR + 'preload-enable.png')
self.pixmaps['preloadDisabled'] = QPixmap(IMAGE_DIR + 'preload-disable.png')
self.pixmaps['favoritesEnabled'] = QPixmap(IMAGE_DIR + 'favorites-enable.png')
self.pixmaps['favoritesDisabled'] = QPixmap(IMAGE_DIR + 'favorites-disable.png')
self.pixmaps['watchlaterEnabled'] = QPixmap(IMAGE_DIR + 'watchLater-enable.png')
self.pixmaps['watchlaterDisabled'] = QPixmap(IMAGE_DIR + 'watchLater-disable.png')
self.__videoHandler = videoHandler
settings = Settings("videoview")
layout = parent.layout()
self.thumbnailCanvas = QLabel()
self.thumbnailCanvas.setFixedSize(240, 135)
self.thumbnailCanvas.setScaledContents(True)
self.thumbnailCanvas.setStyleSheet('margin : 20px')
layout.addWidget(self.thumbnailCanvas, row, 0, 3, 1, Qt.AlignCenter)
ThumbnailLoader(self)
infoTop = QHBoxLayout()
title = ClickableLabel(videoHandler.title().strip())
title.setStyleSheet(settings.get("title-style", "font-weight : bold; text-align : left"))
title.setCursor(Qt.PointingHandCursor)
title.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
title.clicked.connect(self.__play)
infoTop.addWidget(title)
channel = ClickableLabel('by ' + videoHandler.channel().strip())
channel.setCursor(Qt.PointingHandCursor)
channel.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
channel.clicked.connect(self.emitChannelClicked)
channel.setStyleSheet(settings.get("channel-style", "text-align : left"))
infoTop.addWidget(channel)
parent.layout().addLayout(infoTop, row, 1)
description = "No description"
if videoHandler.description() :
description = videoHandler.description()
descriptionText = QLabel(description)
descriptionText.setAlignment(Qt.AlignTop)
descriptionText.setWordWrap(True)
descriptionText.setFixedHeight(100)
descriptionText.setStyleSheet(settings.get("description-style", ""))
descriptionText.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,
QSizePolicy.Fixed))
descriptionText.setMinimumWidth(600)
parent.layout().addWidget(descriptionText, row + 1, 1, 2, 1)
uploadTime = QLabel(self.getTimeSince(videoHandler.uploadTime()))
uploadTime.setStyleSheet(settings.get("uploadtime-style", "text-align : right; vertical-align : center"))
layout.addWidget(uploadTime, row, 2)
self.optionsBar = QHBoxLayout()
'''
self.play = ClickableLabel()
self.play.setPixmap(QPixmap(IMAGE_DIR + 'play.png'))
self.play.clicked.connect(self.__play)
'''
self.preload = ToggleLabel()
self.preload.setStatePixmap(self.pixmaps['preloadEnabled'], True)
self.preload.setStatePixmap(self.pixmaps['preloadDisabled'], False)
self.preload.setState(videoHandler.finishedDownload())
self.preload.toggled.connect(self.__togglePreload)
self.optionsBar.addWidget(self.preload)
self.favourite = ToggleLabel()
self.favouritePlaylist = videoHandler.service().userPlaylist('favorites')
self.favourite.setStatePixmap(self.pixmaps['favoritesEnabled'], True)
self.favourite.setStatePixmap(self.pixmaps['favoritesDisabled'], False)
self.favourite.setState(self.favouritePlaylist.contains(videoHandler))
self.favourite.toggled.connect(self.__toggleFavourite)
self.optionsBar.addWidget(self.favourite)
self.watchlater = ToggleLabel()
self.watchlaterPlaylist = videoHandler.service().userPlaylist('watchLater')
self.watchlater.setStatePixmap(self.pixmaps['watchlaterEnabled'], True)
self.watchlater.setStatePixmap(self.pixmaps['watchlaterDisabled'], False)
self.watchlater.setState(self.watchlaterPlaylist.contains(videoHandler))
self.watchlater.toggled.connect(self.__toggleWatchlater)
self.optionsBar.addWidget(self.watchlater)
layout.addLayout(self.optionsBar, row + 1, 2)
self.progressBar = QProgressBar()
self.progressBar.setMaximumWidth(150)
self.progressBar.setVisible(False)
layout.addWidget(self.progressBar, row + 2, 2)