本文整理汇总了Python中DPH_Singleton.Singleton类的典型用法代码示例。如果您正苦于以下问题:Python Singleton类的具体用法?Python Singleton怎么用?Python Singleton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Singleton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateTimeline
def updateTimeline(self):
printl("" ,self,"S")
try:
currentTime = self.getPlayPosition()[1] / 90000
totalTime = self.getPlayLength()[1] / 90000
progress = int(( float(currentTime) / float(totalTime) ) * 100)
if totalTime > 100000:
return True
printl("currentTime: " + str(currentTime), self, "C")
printl("totalTime: " + str(totalTime), self, "C")
instance = Singleton()
plexInstance = instance.getPlexInstance()
seekState = self.seekstate
if seekState == self.SEEK_STATE_PAUSE:
printl( "Movies PAUSED time: %s secs of %s @ %s%%" % ( currentTime, totalTime, progress), self,"D" )
plexInstance.getTimelineURL(self.server, "/library/sections/onDeck", self.id, "paused", str(currentTime*1000), str(totalTime*1000))
if seekState == self.SEEK_STATE_PLAY :
printl( "Movies PLAYING time: %s secs of %s @ %s%%" % ( currentTime, totalTime, progress),self,"D" )
plexInstance.getTimelineURL(self.server, "/library/sections/onDeck", self.id, "playing", str(currentTime*1000), str(totalTime*1000))
except Exception, e:
printl("exception: " + str(e), self, "E")
return False
示例2: registerPlexFonts
def registerPlexFonts():
"""
registers fonts for skins
@param: none
@return none
"""
printl2("", "__common__::registerPlexFonts", "S")
printl2("adding fonts", "__common__::registerPlexFonts", "I")
tree = Singleton().getSkinParamsInstance()
#tree = getXmlContent("/usr/lib/enigma2/python/Plugins/Extensions/DreamPlex/skins/" + config.plugins.dreamplex.skins.value +"/params")
for font in tree.findall('font'):
path = str(font.get('path'))
printl2("path: " + str(font.get('path')), "__common__::registerPlexFonts", "D")
size = int(font.get('size'))
printl2("size: " + str(font.get('size')), "__common__::registerPlexFonts", "D")
name = str(font.get('name'))
printl2("name: " + str(font.get('name')), "__common__::registerPlexFonts", "D")
addFont(path, name, size, False)
printl2("added => " + name, "__common__::registerPlexFonts", "I")
printl2("", "__common__::registerPlexFonts", "C")
示例3: handleProgress
def handleProgress(self):
printl("", self, "S")
currentTime = self.getPlayPosition()[1] / 90000
totalTime = self.getPlayLength()[1] / 90000
progress = currentTime / (totalTime/100)
printl( "played time is %s secs of %s @ %s%%" % ( currentTime, totalTime, progress),self, "I" )
instance = Singleton()
plexInstance = instance.getPlexInstance()
if self.multiUser:
plexInstance.getTimelineURL(self.server, "/library/sections/onDeck", self.id, "stopped", str(currentTime*1000), str(totalTime*1000))
#Legacy PMS Server server support before MultiUser version v0.9.8.0 and if we are not connected via myPlex
else:
if currentTime < 30:
printl("Less that 30 seconds, will not set resume", self, "I")
#If we are less than 95% complete, store resume time
elif progress < 95:
printl("Less than 95% progress, will store resume time", self, "I" )
plexInstance.doRequest("http://"+self.server+"/:/progress?key="+self.id+"&identifier=com.plexapp.plugins.library&time="+str(currentTime*1000))
#Otherwise, mark as watched
else:
printl( "Movie marked as watched. Over 95% complete", self, "I")
plexInstance.doRequest("http://"+self.server+"/:/scrobble?key="+self.id+"&identifier=com.plexapp.plugins.library")
printl("", self, "C")
示例4: writeToLog
def writeToLog(dmode, out):
"""
singleton handler for the log file
@param dmode: E, W, S, H, A, C, I
@param out: message string
@return: none
"""
if config.plugins.dreamplex.writeDebugFile.value:
try:
instance = Singleton()
if instance.getLogFileInstance() is "":
openLogFile()
gLogFile = instance.getLogFileInstance()
gLogFile.truncate()
else:
gLogFile = instance.getLogFileInstance()
now = datetime.datetime.now()
gLogFile.write("%02d:%02d:%02d.%07d " % (now.hour, now.minute, now.second, now.microsecond) + " >>> " + str(
dmode) + " <<< " + str(out) + "\n")
gLogFile.flush()
except Exception, ex:
config.plugins.dreamplex.writeDebugFile.value = False
config.plugins.dreamplex.debugMode.save()
printl2("Exception(" + str(type(ex)) + "): " + str(ex), "__common__::writeToLog", "E")
示例5: writeToLog
def writeToLog(dmode, out):
"""
singleton handler for the log file
@param dmode: E, W, S, H, A, C, I
@param out: message string
@return: none
"""
try:
# =======================================================================
# if gLogFile is None:
# openLogFile()
# =======================================================================
instance = Singleton()
if instance.getLogFileInstance() is "":
openLogFile()
gLogFile = instance.getLogFileInstance()
gLogFile.truncate()
else:
gLogFile = instance.getLogFileInstance()
now = datetime.datetime.now()
gLogFile.write(
"%02d:%02d:%02d.%07d " % (now.hour, now.minute, now.second, now.microsecond)
+ " >>> "
+ str(dmode)
+ " <<< "
+ str(out)
+ "\n"
)
gLogFile.flush()
except Exception, ex:
printl2("Exception(" + str(type(ex)) + "): " + str(ex), "__common__::writeToLog", "E")
示例6: getGuiElements
def getGuiElements():
printl("", "DP_ViewFactory::getGuiElements", "S")
tree = Singleton().getSkinParamsInstance()
guiElements = {}
for guiElement in tree.findall('guiElement'):
name = str(guiElement.get('name'))
path = str(guiElement.get('path'))
guiElements[name] = path
printl("guiElements: " + str(guiElements), "DP_ViewFactory::getGuiElements", "D")
printl("", "DP_ViewFactory::getGuiElements", "C")
return guiElements
示例7: playEntry
def playEntry(self, selection):
printl("-> in DP_ListMain", self, "S")
media_id = selection[1]['Id']
server = selection[1]['ArtPoster']
instance = Singleton()
plexInstance = instance.getPlexInstance()
print "server =>" + server
url = plexInstance.playStream(media_id, server, False)
sref = eServiceReference(0x1001, 0, str(url))
sref.setName("DreamPlex")
self.sref = sref
self.session.open(DP_Player, sref, self)
示例8: loadSkinParams
def loadSkinParams():
printl2("", "__common__::loadSkinParams", "S")
global skinAuthors
global skinCompatibility
global skinResolution
tree = Singleton().getSkinParamsInstance()
for skinParams in tree.findall('skinParams'):
skinCompatibility = str(skinParams.get('compatibility'))
skinAuthors = str(skinParams.get('skinner'))
skinResolution = str(skinParams.get('resolution'))
printl2("", "__common__::loadSkinParams", "C")
示例9: keyYellow
def keyYellow(self):
printl("", self, "S")
if self.useMappings:
serverID = self.currentId
self.session.open(DPS_Mappings, serverID)
elif self.current.localAuth.value:
# now that we know the server we establish global plexInstance
self.plexInstance = Singleton().getPlexInstance(PlexLibrary(self.session, self.current))
ipInConfig = "%d.%d.%d.%d" % tuple(self.current.ip.value)
token = self.plexInstance.getPlexUserTokenForLocalServerAuthentication(ipInConfig)
if token:
self.current.myplexLocalToken.value = token
self.current.myplexLocalToken.save()
self.session.open(
MessageBox,
(_("Local Token:") + "\n%s \n" + _("for the user:") + "\n%s")
% (token, self.current.myplexTokenUsername.value),
MessageBox.TYPE_INFO,
)
else:
response = self.plexInstance.getLastResponse()
self.session.open(
MessageBox,
(_("Error:") + "\n%s \n" + _("for the user:") + "\n%s")
% (response, self.current.myplexTokenUsername.value),
MessageBox.TYPE_INFO,
)
printl("", self, "C")
示例10: stopTranscoding
def stopTranscoding(self):
printl("", self, "S")
if self.multiUser:
self.timelinewatcherthread_wait.set()
self.timelinewatcherthread_stop.set()
instance = Singleton()
plexInstance = instance.getPlexInstance()
if self.universalTranscoder:
plexInstance.doRequest("http://"+self.server+"/video/:/transcode/universal/stop?session=" + self.transcodingSession)
else:
plexInstance.doRequest("http://"+self.server+"/video/:/transcode/segmented/stop?session=" + self.transcodingSession)
printl("", self, "C")
示例11: initMenu
def initMenu(self):
printl("", self, "S")
tree = Singleton().getSkinParamsInstance()
for menuScreen in tree.findall('menuScreen'):
name = str(menuScreen.get('name'))
if name == self.screenName:
myType = str(menuScreen.get('type'))
if myType == "horizontal":
self.g_horizontal_menu = True
self.highlightedColor = str(menuScreen.get('highlighted'))
self.normalColor = str(menuScreen.get('normal'))
printl("", self, "C")
示例12: keyBlue
def keyBlue(self):
printl("", self, "S")
# now that we know the server we establish global plexInstance
self.plexInstance = Singleton().getPlexInstance(PlexLibrary(self.session, self.current))
token = self.plexInstance.getNewMyPlexToken()
if token:
self.session.open(
MessageBox,
(_("myPlex Token:") + "\n%s \n" + _("for the user:") + "\n%s")
% (token, self.current.myplexTokenUsername.value),
MessageBox.TYPE_INFO,
)
else:
response = self.plexInstance.getLastResponse()
self.session.open(
MessageBox,
(_("Error:") + "\n%s \n" + _("for the user:") + "\n%s")
% (response, self.current.myplexTokenUsername.value),
MessageBox.TYPE_INFO,
)
printl("", self, "C")
示例13: getMiniTvParams
def getMiniTvParams(self):
printl("", self, "S")
tree = Singleton().getSkinParamsInstance()
width = 400
height = 225
printl("menuType: " + str(self.menuType), self, "D")
for miniTv in tree.findall('miniTv'):
name = str(miniTv.get('name'))
if name == self.menuType:
width = miniTv.get('width')
height = miniTv.get('height')
printl("width: " + str(width) + " - height: " + str(height), self, "D")
printl("", self, "C")
return int(width), int(height)
示例14: openLogFile
def openLogFile():
"""
singleton instance for logfile
@param: none
@return: none
"""
# printl2("", "openLogFile", "S")
logDir = config.plugins.dreamplex.logfolderpath.value
now = datetime.datetime.now()
try:
instance = Singleton()
instance.getLogFileInstance(open(logDir + "dreamplex.log", "w"))
except Exception, ex:
printl2("Exception(" + str(type(ex)) + "): " + str(ex), "openLogFile", "E")
示例15: openLogFile
def openLogFile():
"""
singleton instance for logfile
"""
#printl2("", "openLogFile", "S")
logDir = config.plugins.dreamplex.logfolderpath.value
try:
if os.path.exists(logDir + "dreamplex_former.log"):
os.remove(logDir + "dreamplex_former.log")
if os.path.exists(logDir + "dreamplex.log"):
shutil.copy2(logDir + "dreamplex.log", logDir + "dreamplex_former.log")
instance = Singleton()
instance.getLogFileInstance(open(logDir + "dreamplex.log", "w"))
except Exception, ex:
printl2("Exception(" + str(type(ex)) + "): " + str(ex), "openLogFile", "E")