本文整理汇总了Python中xbmcvfs.copy函数的典型用法代码示例。如果您正苦于以下问题:Python copy函数的具体用法?Python copy怎么用?Python copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VideoWindow
def VideoWindow():
log("VideoWindow, VWPath = " + str(VWPath))
FreshInstall = False
#Copy VideoWindow Patch file
try:
if xbmcgui.Window(10000).getProperty("PseudoTVRunning") != "True":
if not FileAccess.exists(VWPath):
log("VideoWindow, VWPath not found")
FreshInstall = True
xbmcvfs.copy(flePath, VWPath)
if FileAccess.exists(VWPath):
log('custom_script.pseudotv.live_9506.xml Copied')
VideoWindowPatch()
if FreshInstall == True:
xbmc.executebuiltin("ReloadSkin()")
else:
raise
else:
log("VideoWindow, VWPath found")
VideoWindowPatch()
except Exception:
VideoWindowUninstall()
VideoWindowUnpatch()
Error = True
pass
示例2: _copy_moviethumbs
def _copy_moviethumbs( self ):
count = 0
processeditems = 0
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["file", "title", "thumbnail", "year"], "filter": {"field": "path", "operator": "contains", "value": "%s"}}, "id": 1}' % self.path)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = json.loads(json_query)
if json_response.has_key('result') and (json_response['result'] != None) and (json_response['result'].has_key('movies')):
totalitems = len( json_response['result']['movies'] )
for item in json_response['result']['movies']:
if self.dialog.iscanceled():
log('script cancelled')
return
processeditems = processeditems + 1
self.dialog.update( int( float( processeditems ) / float( totalitems ) * 100), LANGUAGE(32005) + ': ' + str( count + 1 ) )
name = item['title']
year = str(item['year'])
artwork = item['thumbnail']
tmp_filename = name + ' (' + year + ')' + '.jpg'
filename = clean_filename( tmp_filename )
# test file path with movie_content to find source name
moviethumbspath = self.moviethumbspath
if self.split_movies_sources == "true" and self.movies_content.has_key(str(item['file'])):
moviethumbspath = os.path.join( self.moviethumbspath, self.movies_content[str(item['file'])])
if artwork != '':
try:
xbmcvfs.copy( xbmc.translatePath( artwork ), os.path.join( moviethumbspath, filename ) )
count += 1
except:
log( 'failed to copy moviethumb' )
log( 'moviethumbs copied: %s' % count )
示例3: copyNode
def copyNode(self, dirs, files, target, origin):
for file in files:
xbmcvfs.copy( os.path.join( origin, file ), os.path.join( target, file ) )
for dir in dirs:
nextDirs, nextFiles = xbmcvfs.listdir( os.path.join( origin, dir ) )
self.copyNode( nextDirs, nextFiles, os.path.join( target, dir ), os.path.join( origin, dir ) )
示例4: restoreColorTheme
def restoreColorTheme():
import shutil
import zipfile
zip_path = None
userThemesPath = os.path.join(userThemesDir,"themes") + os.sep
zip_path = get_browse_dialog(dlg_type=1,heading=ADDON.getLocalizedString(32020),mask=".zip")
if zip_path and zip_path != "protocol://":
#create temp path
temp_path = xbmc.translatePath('special://temp/skinbackup/').decode("utf-8")
if xbmcvfs.exists(temp_path):
shutil.rmtree(temp_path)
xbmcvfs.mkdir(temp_path)
#unzip to temp
if "\\" in zip_path:
delim = "\\"
else:
delim = "/"
zip_temp = xbmc.translatePath('special://temp/' + zip_path.split(delim)[-1]).decode("utf-8")
xbmcvfs.copy(zip_path,zip_temp)
zfile = zipfile.ZipFile(zip_temp)
zfile.extractall(temp_path)
zfile.close()
xbmcvfs.delete(zip_temp)
dirs, files = xbmcvfs.listdir(temp_path)
for file in files:
if file.endswith(".theme") or file.endswith(".jpg"):
sourcefile = os.path.join(temp_path,file)
destfile = os.path.join(userThemesPath,file)
xbmcvfs.copy(sourcefile,destfile)
xbmcgui.Dialog().ok(ADDON.getLocalizedString(32022), ADDON.getLocalizedString(32021))
示例5: ffmpeg_location
def ffmpeg_location():
ffmpeg_src = xbmc.translatePath(ADDON.getSetting('autoplaywiths.ffmpeg'))
if xbmc.getCondVisibility('system.platform.android'):
ffmpeg_dst = '/data/data/%s/ffmpeg' % android_get_current_appid()
if (ADDON.getSetting('autoplaywiths.ffmpeg') != ADDON.getSetting('ffmpeg.last')) or (not xbmcvfs.exists(ffmpeg_dst) and ffmpeg_src != ffmpeg_dst):
xbmcvfs.copy(ffmpeg_src, ffmpeg_dst)
ADDON.setSetting('ffmpeg.last',ADDON.getSetting('autoplaywiths.ffmpeg'))
ffmpeg = ffmpeg_dst
else:
ffmpeg = ffmpeg_src
log(ffmpeg)
if ffmpeg:
try:
st = os.stat(ffmpeg)
if not (st.st_mode & stat.S_IXUSR):
log(st)
try:
os.chmod(ffmpeg, st.st_mode | stat.S_IXUSR)
except Exception as e:
log(e)
except Exception as e:
log(e)
if xbmcvfs.exists(ffmpeg):
return ffmpeg
else:
xbmcgui.Dialog().notification("TVGF", "ffmpeg exe not found!")
示例6: Filter_Fakelight
def Filter_Fakelight(filterimage, pixels):
md5 = hashlib.md5(filterimage).hexdigest()
filename = md5 + "fakelight" + str(pixels) + ".png"
targetfile = os.path.join(ADDON_DATA_PATH, filename)
cachedthumb = xbmc.getCacheThumbName(filterimage)
xbmc_vid_cache_file = os.path.join("special://profile/Thumbnails/Video", cachedthumb[0], cachedthumb)
xbmc_cache_file = os.path.join("special://profile/Thumbnails/", cachedthumb[0], cachedthumb[:-4] + ".jpg")
if filterimage == "":
return ""
if not xbmcvfs.exists(targetfile):
img = None
for i in range(1, 4):
try:
if xbmcvfs.exists(xbmc_cache_file):
img = Image.open(xbmc.translatePath(xbmc_cache_file))
break
elif xbmcvfs.exists(xbmc_vid_cache_file):
img = Image.open(xbmc.translatePath(xbmc_vid_cache_file))
break
else:
filterimage = urllib.unquote(filterimage.replace("image://", "")).decode('utf8')
if filterimage.endswith("/"):
filterimage = filterimage[:-1]
xbmcvfs.copy(filterimage, targetfile)
img = Image.open(targetfile)
break
except:
xbmc.sleep(300)
if not img:
return ""
img = fake_light(img,pixels)
img.save(targetfile)
return targetfile
示例7: _handle_compressed_subs
def _handle_compressed_subs(workdir, compressed_file, ext):
"""
Uncompress 'compressed_file' in 'workdir'.
"""
if ext == 'rar' and kodi_major_version >= 18:
src = 'archive' + '://' + quote_plus(compressed_file) + '/'
(cdirs, cfiles) = xbmcvfs.listdir(src)
for cfile in cfiles:
fsrc = '%s%s' % (src, cfile)
xbmcvfs.copy(fsrc, workdir + cfile)
else:
xbmc.executebuiltin("XBMC.Extract(%s, %s)" % (
compressed_file.encode("utf-8"),
workdir.encode("utf-8")), True)
files = os.listdir(workdir)
files = [f for f in files if is_subs_file(f)]
found_files = []
for fname in files:
if not isinstance(fname, unicode):
fname = fname.decode('utf-8')
found_files.append({
'forced': is_forced_subs_file(fname),
'path': pjoin(workdir, fname)
})
if not found_files:
log(u"Failed to unpack subtitles", level=LOGSEVERE)
return found_files
示例8: _copy_musicvideothumbs
def _copy_musicvideothumbs( self ):
count = 0
processeditems = 0
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": {"properties": ["title", "thumbnail", "artist"], "filter": {"field": "path", "operator": "contains", "value": "%s"}}, "id": 1}' % self.path)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = json.loads(json_query)
if json_response.has_key('result') and (json_response['result'] != None) and (json_response['result'].has_key('musicvideos')):
totalitems = len( json_response['result']['musicvideos'] )
for item in json_response['result']['musicvideos']:
if self.dialog.iscanceled():
log('script cancelled')
return
processeditems = processeditems + 1
self.dialog.update( int( float( processeditems ) / float( totalitems ) * 100), LANGUAGE(32009) + ': ' + str( count + 1 ) )
name = item['title']
artwork = item['thumbnail']
if item['artist']: # bug workaround, musicvideos can end up in the database without an artistname
artist = item['artist'][0]
tmp_filename = artist + ' - ' + name + '.jpg'
else:
tmp_filename = name + '.jpg'
filename = clean_filename( tmp_filename )
if artwork != '':
try:
xbmcvfs.copy( xbmc.translatePath( artwork ), os.path.join( self.musicvideothumbspath, filename ) )
count += 1
except:
log( 'failed to copy musicvideothumb' )
log( 'musicvideothumbs copied: %s' % count )
示例9: run
def run(self):
#get a list of all the settings we can manipulate via json
json_response = json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "id":1, "method":"Settings.GetSettings","params":{"level":"advanced"}}'))
settings = json_response['result']['settings']
for aSetting in settings:
self.settings_allowed.append(aSetting['id'])
#parse the existing xml file and get all the settings
root_nodes = self.__parseNodes(self.doc.documentElement)
for aNode in root_nodes:
secondary_list = self.__parseNodes(self.doc.getElementsByTagName(aNode.name)[0])
for secondNode in secondary_list:
#if the node does not have children and is not default
if(not secondNode.hasChildren and not secondNode.isDefault):
if(secondNode.json_name() in self.settings_allowed):
self.found_settings.append(secondNode)
#go through all the found settings and update them
for aSetting in self.found_settings:
utils.log("updating: " + aSetting.json_name() + ", value: " + aSetting.value)
#check for boolean and numeric values
if(aSetting.value.isdigit() or (aSetting.value == 'true' or aSetting.value == 'false')):
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "id":1, "method":"Settings.SetSettingValue","params":{"setting":"' + aSetting.json_name() + '","value":' + aSetting.value + '}}')
else:
xbmc.executeJSONRPC('{"jsonrpc":"2.0", "id":1, "method":"Settings.SetSettingValue","params":{"setting":"' + aSetting.json_name() + '","value":"' + utils.encode(aSetting.value) + '"}}')
#make a copy of the guisettings file to make user based restores easier
xbmcvfs.copy(self.settingsFile, xbmc.translatePath("special://home/userdata/guisettings.xml.restored"))
示例10: HubSwap
def HubSwap(): # Swap Org/Hub versions if 'Hub Installer' found.
xbmc.log('script.pseudotv.live-service: HubSwap')
try:#unknown Amazon firetv error encountered here, requires investigation
icon = ADDON_PATH + '/icon'
HUB = chanlist.plugin_ok('plugin.program.addoninstaller')
if HUB == True:
xbmc.log('script.pseudotv.live-service: HubSwap - Hub Edition')
REAL_SETTINGS.setSetting("Hub","true")
try:
xbmcvfs.delete(icon + '.png')
except:
pass
try:
xbmcvfs.copy(icon + 'HUB', icon + '.png')
except:
pass
if NOTIFY == 'true':
xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoTV Live","Hub-Edition Activated", 4000, THUMB) )
else:
xbmc.log('script.pseudotv.live-service: HubSwap - Master')
REAL_SETTINGS.setSetting("Hub","false")
try:
xbmcvfs.delete(icon + '.png')
except:
pass
try:
xbmcvfs.copy(icon + 'OEM', icon + '.png')
except:
pass
except:
REAL_SETTINGS.setSetting("Hub","false")
pass
示例11: copy
def copy(file, path):
try: # Post Dharma
import xbmcvfs
size_file, hash_file = xbmc.subHashAndFileSize(file)
try:
size_dest, hash_dest = xbmc.subHashAndFileSize(os.path.join(path, os.path.basename(file)))
except:
size_dest = 0
hash_dest = ""
if hash_file != hash_dest:
xbmcvfs.copy(file, os.path.join(path, os.path.basename(file)))
if __settings__.getSetting( "delete" ) == "true":
size_dest, hash_dest = xbmc.subHashAndFileSize(os.path.join(path, os.path.basename(file)))
if hash_file == hash_dest:
xbmcvfs.delete(file)
log("Deleted %s" % file)
except: # Dharma
import shutil, filecmp
if not os.path.exists(os.path.join(path, os.path.basename(file))):
shutil.copy(file,os.path.join(path, os.path.basename(file)))
if filecmp.cmp(file, os.path.join(path, os.path.basename(file))) and __settings__.getSetting( "delete" ) == "true":
os.remove(file)
log("Deleted %s" % file)
示例12: _enableKeymap
def _enableKeymap(self):
try:
xbmcvfs.copy(self.KEYMAPSOURCEFILE, self.KEYMAPDESTFILE)
xbmc.executebuiltin('Action(reloadkeymaps)')
log("SonosVolumeRedirect: Installed custom keymap")
except:
log("SonosVolumeRedirect: Failed to copy & load custom keymap: %s" % traceback.format_exc(), xbmc.LOGERROR)
示例13: pchkmedia
def pchkmedia():
try:
KmediaDir = "plugin.video.kmediatorrent"
f = open(os.path.join(addonspath,KmediaDir,"addon.xml"), 'r')
AddOnId=f.read()
f.close
except:
try:
KmediaDir = "plugin.video.kmediatorrent-2.3.7"
f = open(os.path.join(addonspath,KmediaDir,"addon.xml"), 'r')
AddOnId=f.read()
f.close
except:
return False
#if AddOnId == "" : return False
if not 'version="2.3.7"' in AddOnId: return False
destino = os.path.join(addonspath,KmediaDir,"resources","settings.xml")
if os.path.isfile(destino):
if not xbmcvfs.copy(os.path.join(__cwd__ , "resources" , "parches" , "kmediatorrent" , "settings.xml") , destino) : return False
else: return False
destino = os.path.join(addonspath,KmediaDir,"resources","site-packages","kmediatorrent","player.py")
if os.path.isfile(destino):
if not xbmcvfs.copy(os.path.join(__cwd__ , "resources" , "parches" , "kmediatorrent" , "player.py") , destino) : return False
else: return False
return True
示例14: pchplexusstreams
def pchplexusstreams():
proceso = 0
proceso2 = 0
destinoset = os.path.join(addonspath,"plugin.video.plexus-streams","resources","settings.xml")
if os.path.isfile(destinoset):
md5sum = txtmd5(destinoset)
if md5sum == "d9ff4538382826cb676f83fad177d8a9":
proceso = 1
elif md5sum == "bde9fe5ba3d7d0159f0c5b127a5e0181":
proceso = 2
else: proceso = 3
else: proceso = 0
destinoace = os.path.join(addonspath,"plugin.video.plexus-streams","resources","core","acestream.py")
if os.path.isfile(destinoace):
md5sum = txtmd5(destinoace)
if md5sum == "5e06800233f5d49fa2e11353ef33533f":
proceso2 = 1
elif md5sum == "63267830d43361a408e8b34695cbb073":
proceso = 2
else: proceso = 3
else: proceso = 0
if proceso == 1 and proceso2 == 1:
if not xbmcvfs.copy(os.path.join(__cwd__ , "resources" , "parches" , "plexus-streams" , "settings.xml") , destinoset) : return 0
if not xbmcvfs.copy(os.path.join(__cwd__ , "resources" , "parches" , "plexus-streams" , "acestream.py") , destinoace) : return 0
return proceso
else: return proceso
示例15: create_color_swatch_image
def create_color_swatch_image(self, colorstring):
'''helper method to generate a colorized image using PIL'''
if colorstring:
paths = []
paths.append(u"%s%s.png" % (COLORFILES_PATH, colorstring))
if xbmcvfs.exists(SKINCOLORFILE):
paths.append(u"%s%s.png" % (SKINCOLORFILES_PATH, colorstring))
for color_image_file in paths:
if not xbmcvfs.exists(color_image_file):
if SUPPORTS_PIL:
# create image with PIL
try:
colorstring = colorstring.strip()
if colorstring[0] == '#':
colorstring = colorstring[1:]
a, r, g, b = colorstring[:2], colorstring[2:4], colorstring[4:6], colorstring[6:]
a, r, g, b = [int(n, 16) for n in (a, r, g, b)]
color = (r, g, b, a)
img = Image.new("RGBA", (16, 16), color)
img.save(color_image_file)
del img
except Exception as exc:
log_exception(__name__, exc)
else:
# create image with online service if no pil support
xbmcvfs.copy( "https://dummyimage.com/16/%s/%s.png" % (colorstring[2:],colorstring[2:]), color_image_file )
log_msg("Local PIL module not available, generating color swatch image with online service", xbmc.LOGWARNING)
return color_image_file