本文整理匯總了Python中xbmcvfs.rename方法的典型用法代碼示例。如果您正苦於以下問題:Python xbmcvfs.rename方法的具體用法?Python xbmcvfs.rename怎麽用?Python xbmcvfs.rename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xbmcvfs
的用法示例。
在下文中一共展示了xbmcvfs.rename方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: fixKeymaps
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def fixKeymaps():
# Fix the keymap file name if it's been changed or the old name was being used
name = getKeyMapsFileName()
old = getOldKeyMapsFileName()
dir = getKeyMapsPath("*")
full_name = getKeyMapsPath(name)
try:
debugTrace("Getting contents of keymaps directory " + dir)
files = (glob.glob(dir))
if not full_name in files and len(files) > 0:
for file in files:
if (name in file) or (old in file):
infoTrace("common.py", "Renaming " + file + " to " + full_name)
xbmcvfs.rename(file, full_name)
xbmc.sleep(100)
# Wait 10 seconds for rename to happen otherwise quit and let it fail in the future
for i in range(0, 9):
if xbmcvfs.exists(full_name): break
xbmc.sleep(1000)
return True
except Exception as e:
errorTrace("common.py", "Problem fixing the keymap filename.")
errorTrace("common.py", str(e))
return False
示例2: fix_update
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def fix_update():
if os.path.exists(os.path.join(CONFIG.USERDATA, 'autoexec.py')):
temp = os.path.join(CONFIG.USERDATA, 'autoexec_temp.py')
if os.path.exists(temp):
xbmcvfs.delete(temp)
xbmcvfs.rename(os.path.join(CONFIG.USERDATA, 'autoexec.py'), temp)
xbmcvfs.copy(os.path.join(CONFIG.PLUGIN, 'resources', 'libs', 'autoexec.py'),
os.path.join(CONFIG.USERDATA, 'autoexec.py'))
dbfile = os.path.join(CONFIG.DATABASE, latest_db('Addons'))
try:
os.remove(dbfile)
except:
logging.log("Unable to remove {0}, Purging DB".format(dbfile))
purge_db_file(dbfile)
from resources.libs.common import tools
tools.kill_kodi(over=True)
示例3: play_url_ind
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def play_url_ind(self, index=0, title='', icon='', thumb=''):
self.log.out('play')
self.player=_TSPlayer()
lnk=self.get_link(index,title,icon,thumb)
if not lnk: return False
self.player.link=lnk
self.player.vod=True
if self.progress:self.progress.close()
item = xbmcgui.ListItem(title,thumb,icon,path=lnk)
if self.local:
xbmcvfs.rename(lnk,lnk)
xbmc.Player().play(lnk,item)
else:
self.player.play(lnk,item)
while self.player.active and not self.local:
self.loop()
xbmc.sleep(300)
if xbmc.abortRequested:
self.log.out("XBMC is shutting down")
break
self.log.out('ended play')
示例4: import_advancedxml
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def import_advancedxml():
userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8')))
advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml')
advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml')
if xbmcvfs.exists(advancedsettings_var):
print("An advanced settings XML file already exists")
if xbmcvfs.exists(advancedsettingsbackup_var):
print("An advanced settings backup already exists")
xbmcvfs.delete(advancedsettingsbackup_var)
xbmcvfs.rename(advancedsettings_var,advancedsettingsbackup_var)
advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"]
advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"]
index = xbmcgui.Dialog().select(translate(40185), advancedname)
if index > -1:
download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000))
mensagemok(translate(40000),translate(40060))
else:
xbmcvfs.rename(advancedsettings_var,advancedsettingsbackup_var)
advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"]
advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"]
index = xbmcgui.Dialog().select(translate(40185), advancedname)
if index > -1:
download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000))
mensagemok(translate(40000),translate(40060))
else:
print("No advancedsettings.xml in the system yet")
advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"]
advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"]
index = xbmcgui.Dialog().select(translate(40185), advancedname)
if index > -1:
download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000))
mensagemok(translate(40000),translate(40060))
xbmc.executebuiltin("Container.Refresh")
示例5: recoverbackup_advancedxml
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def recoverbackup_advancedxml():
userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8')))
advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml')
advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml')
xbmcvfs.delete(advancedsettings_var)
xbmcvfs.rename(advancedsettingsbackup_var,advancedsettings_var)
mensagemok(translate(40000),translate(40062))
xbmc.executebuiltin("Container.Refresh")
示例6: break_sopcast
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def break_sopcast():
if xbmc.getCondVisibility('system.platform.windows'):
import _winreg
aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
try:
aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath', 0, _winreg.KEY_READ)
name, value, type = _winreg.EnumValue(aKey, 0)
codec_file = os.path.join(os.path.join(value.replace("SopCast.exe", "")), 'codec', 'sop.ocx.old')
_winreg.CloseKey(aKey)
if xbmcvfs.exists(codec_file): xbmcvfs.rename(codec_file,
os.path.join(os.path.join(value.replace("SopCast.exe", "")),
'codec', 'sop.ocx'))
except:
pass
示例7: break_sopcast
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def break_sopcast():
if xbmc.getCondVisibility('system.platform.windows'):
import _winreg
aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
try:
aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath',0, _winreg.KEY_READ)
name, value, type = _winreg.EnumValue(aKey, 0)
codec_file = os.path.join(os.path.join(value.replace("SopCast.exe","")),'codec','sop.ocx.old')
_winreg.CloseKey(aKey)
if xbmcvfs.exists(codec_file): xbmcvfs.rename(codec_file,os.path.join(os.path.join(value.replace("SopCast.exe","")),'codec','sop.ocx'))
except:pass
示例8: rename
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def rename(path, new_name, silent=False, strict=False, vfs=True):
"""
Renombra un archivo o carpeta
@param path: ruta del fichero o carpeta a renombrar
@type path: str
@param new_name: nuevo nombre
@type new_name: str
@rtype: bool
@return: devuelve False en caso de error
"""
path = encode(path)
try:
if xbmc_vfs and vfs:
path_end = path
if path_end.endswith('/') or path_end.endswith('\\'):
path_end = path_end[:-1]
dest = encode(join(dirname(path_end), new_name))
result = xbmcvfs.rename(path, dest)
if not result and not strict:
logger.error("ERROR al RENOMBRAR el archivo: %s. Copiando y borrando" % path)
if not silent:
dialogo = platformtools.dialog_progress("Copiando archivo", "")
result = xbmcvfs.copy(path, dest)
if not result:
return False
xbmcvfs.delete(path)
return bool(result)
elif path.lower().startswith("smb://"):
new_name = encode(new_name, True)
samba.rename(path, join(dirname(path), new_name))
else:
new_name = encode(new_name, False)
os.rename(path, os.path.join(os.path.dirname(path), new_name))
except:
logger.error("ERROR al renombrar el archivo: %s" % path)
if not silent:
logger.error(traceback.format_exc())
platformtools.dialog_notification("Error al renombrar", path)
return False
else:
return True
示例9: file_rename
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def file_rename(f, newFile):
import xbmcvfs
return xbmcvfs.rename(f, newFile)
示例10: rename
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def rename(src, dest, quiet=False):
if not quiet:
msg = 'Confirmation'
msg2 = 'Please confirm rename file!'
if not confirm(msg, msg2, src): return False
xbmcvfs.rename(src, dest)
示例11: _double_dot_fix_hack
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def _double_dot_fix_hack(video_filename):
"""Corrects filename of downloaded subtitle from Foo-Blah..srt to Foo-Blah.es.srt"""
log(u"video_filename = %s" % video_filename)
work_path = video_filename
if _subtitles_setting('storagemode'):
custom_subs_path = _subtitles_setting('custompath')
if custom_subs_path:
_, fname = os.path.split(video_filename)
work_path = pjoin(custom_subs_path, fname)
log(u"work_path = %s" % work_path)
parts = work_path.rsplit('.', 1)
if len(parts) > 1:
rest = parts[0]
for ext in ('srt', 'ssa', 'sub', 'idx'):
bad = rest + '..' + ext
old = rest + '.es.' + ext
if xbmcvfs.exists(bad):
log(u"%s exists" % bad)
if xbmcvfs.exists(old):
log(u"%s exists, removing" % old)
xbmcvfs.delete(old)
log(u"renaming %s to %s" % (bad, old))
xbmcvfs.rename(bad, old)
示例12: move
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def move(path, dest, silent=False, strict=False, vfs=True):
"""
Mueve un archivo
@param path: ruta del fichero a mover
@type path: str
@param dest: ruta donde mover
@type dest: str
@rtype: bool
@return: devuelve False en caso de error
"""
try:
if xbmc_vfs and vfs:
if not exists(path): return False
path = encode(path)
dest = encode(dest)
result = xbmcvfs.rename(path, dest)
if not result and not strict:
logger.error("ERROR al MOVER el archivo: %s. Copiando y borrando" % path)
if not silent:
dialogo = platformtools.dialog_progress("Copiando archivo", "")
result = xbmcvfs.copy(path, dest)
if not result:
return False
xbmcvfs.delete(path)
return bool(result)
# samba/samba
elif path.lower().startswith("smb://") and dest.lower().startswith("smb://"):
dest = encode(dest, True)
path = encode(path, True)
samba.rename(path, dest)
# local/local
elif not path.lower().startswith("smb://") and not dest.lower().startswith("smb://"):
dest = encode(dest)
path = encode(path)
os.rename(path, dest)
# mixto En este caso se copia el archivo y luego se elimina el de origen
else:
if not silent:
dialogo = platformtools.dialog_progress("Copiando archivo", "")
return copy(path, dest) == True and remove(path) == True
except:
logger.error("ERROR al mover el archivo: %s a %s" % (path, dest))
if not silent:
logger.error(traceback.format_exc())
return False
else:
return True
示例13: loop
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def loop(self):
pos=self.pos
if len(self.player.coms)>0:
comm=self.player.coms[0]
self.player.coms.remove(comm)
self.TSpush(comm)
if self.player.isPlaying():
if self.player.getTotalTime()>0: cpos= int((1-(self.player.getTotalTime()-self.player.getTime())/self.player.getTotalTime())*100)
else: cpos=0
if cpos in pos:
pos.remove(cpos)
comm='PLAYBACK '+self.player.link.replace('\r','').replace('\n','')+' %s'%cpos
self.TSpush(comm)
if self.tsserv.event and self.save:
self.log.out('Try to save file in loop')
comm='SAVE %s path=%s'%(self.tsserv.event[0]+' '+self.tsserv.event[1],urllib.quote(self.filename))
self.TSpush(comm)
self.tsserv.event=None
succ=True
self.saved=True
if self.saved and self.player.started:
self.log.out('saving content')
if self.player.isPlaying() and os.path.exists(self.filename.decode('utf-8')):
xbmc.sleep(10000)
self.log.out('Start local file')
self.tsserv.got_url=self.filename
self.local=True
self.sm('Start Local File')
try: time1=self.player.getTime()
except: time1=0
i = xbmcgui.ListItem("***%s"%self.title)
i.setProperty('StartOffset', str(time1))
self.log.out('Play local file')
try:
xbmcvfs.rename(self.filename.decode('utf-8'),self.filename.decode('utf-8'))
xbmc.Player().play(self.filename.decode('utf-8'),i)
except:
xbmcvfs.rename(self.filename,self.filename)
xbmc.Player().play(self.filename,i)
self.local=True
self.player.active=False
示例14: loop
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import rename [as 別名]
def loop(self):
if self.local: return
pos=self.pos
self.log.out('1')
if len(self.player.coms)>0:
comm=self.player.coms[0]
self.player.coms.remove(comm)
self.TSpush(comm)
self.log.out('2')
if self.player.isPlaying():
if self.player.getTotalTime()>0: cpos= int((1-(self.player.getTotalTime()-self.player.getTime())/self.player.getTotalTime())*100)
else: cpos=0
if cpos in pos:
pos.remove(cpos)
comm='PLAYBACK '+self.player.link.replace('\r','').replace('\n','')+' %s'%cpos
self.TSpush(comm)
self.log.out('3')
if self.tsserv.event and self.save:
self.log.out('Try to save file in loop')
try: comm='SAVE %s path=%s'%(self.tsserv.event[0]+' '+self.tsserv.event[1],urllib.quote(self.filename))
except: comm='SAVE %s path=%s'%(self.tsserv.event[0]+' '+self.tsserv.event[1],urllib.quote(self.filenam.encode('utf-8')))
self.TSpush(comm)
self.tsserv.event=None
succ=True
self.saved=True
self.log.out('4')
if self.saved:
self.log.out('4.1')
try: tt=os.path.exists(self.filename.decode('utf-8'))
except: tt=os.path.exists(self.filename)
if self.player.isPlaying() and tt:
xbmc.sleep(3000)
self.log.out('Start local file')
self.tsserv.got_url=self.filename
self.local=True
self.sm('Start Local File')
try: time1=self.player.getTime()
except: time1=0
i = xbmcgui.ListItem("***%s"%self.title)
i.setProperty('StartOffset', str(time1))
self.log.out('Play local file')
try:
xbmcvfs.rename(self.filename.decode('utf-8'),self.filename.decode('utf-8'))
xbmc.Player().play(self.filename.decode('utf-8'),i)
except:
xbmcvfs.rename(self.filename,self.filename)
xbmc.Player().play(self.filename,i)
self.local=True
self.player.active=False
saved=False
self.save=False
self.log.out('loop succ')