Python xbmcvfs.rename() Examples

The following are 16 code examples of xbmcvfs.rename(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xbmcvfs , or try the search function .
Example #1
Source File: common.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #2
Source File: db.py    From plugin.program.openwizard with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #3
Source File: TSCore.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
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') 
Example #4
Source File: advancedfunctions.py    From program.plexus with GNU General Public License v2.0 5 votes vote down vote up
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") 
Example #5
Source File: advancedfunctions.py    From program.plexus with GNU General Public License v2.0 5 votes vote down vote up
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") 
Example #6
Source File: sopcast.py    From program.plexus with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #7
Source File: advancedfunctions.py    From program.plexus with GNU General Public License v2.0 5 votes vote down vote up
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") 
Example #8
Source File: advancedfunctions.py    From program.plexus with GNU General Public License v2.0 5 votes vote down vote up
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") 
Example #9
Source File: sopcast.py    From program.plexus with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #10
Source File: filetools.py    From addon with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #11
Source File: utils.py    From script.module.clouddrive.common with GNU General Public License v3.0 5 votes vote down vote up
def file_rename(f, newFile):
        import xbmcvfs
        return xbmcvfs.rename(f, newFile) 
Example #12
Source File: vfs.py    From plugin.git.browser with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #13
Source File: service.py    From service.subtitles.subdivx with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #14
Source File: filetools.py    From addon with GNU General Public License v3.0 4 votes vote down vote up
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 
Example #15
Source File: ASCore.py    From ru with GNU General Public License v2.0 4 votes vote down vote up
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 
Example #16
Source File: TSCore.py    From ru with GNU General Public License v2.0 4 votes vote down vote up
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')