本文整理匯總了Python中xbmcvfs.copy方法的典型用法代碼示例。如果您正苦於以下問題:Python xbmcvfs.copy方法的具體用法?Python xbmcvfs.copy怎麽用?Python xbmcvfs.copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xbmcvfs
的用法示例。
在下文中一共展示了xbmcvfs.copy方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __copyLauncherScriptsToUserdata
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def __copyLauncherScriptsToUserdata(self):
log.info('__copyLauncherScriptsToUserdata')
oldBasePath = os.path.join(util.getAddonInstallPath(), 'resources', 'scriptfiles')
newBasePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')
files = []
# Copy applaunch shell script/batch file
if self.env == 'win32':
files.append('applaunch.bat')
else:
files.append('applaunch.sh')
# Copy VBS files
if self.env == 'win32' and __addon__.getSetting(util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true':
files += ['applaunch-vbs.bat', 'LaunchKodi.vbs', 'Sleep.vbs']
for f in files:
if not xbmcvfs.exists(os.path.join(newBasePath, f)):
log.debug("Copying file {0} from {1} to {2}".format(f, oldBasePath, newBasePath))
if not xbmcvfs.copy(os.path.join(oldBasePath, f), os.path.join(newBasePath, f)):
log.warn("Error copying file")
示例2: download_thumb
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def download_thumb(self, thumburl, destfilename):
log.info("begin download_thumb using requests module: thumburl = %s" % thumburl)
# Download file to tmp folder
tmp = util.joinPath(util.getTempDir(), os.path.basename(destfilename))
log.info("download_thumb: start downloading to temp file: %s" % tmp)
response = requests.get(thumburl, headers=WebScraper._headers, stream=True)
log.info("download_thumb: status code = %s" % response.status_code)
if response.status_code != 200:
log.info("download_thumb: invalid response status code. Can't download image.")
return
with open(tmp, 'wb') as f:
response.raw.decode_content = True
shutil.copyfileobj(response.raw, f)
log.info("download_thumb: copy from temp file to final destination: %s" % destfilename)
# Copy from the tmp folder to the target location
xbmcvfs.copy(tmp, destfilename)
xbmcvfs.delete(tmp)
log.info("end download_thumb")
示例3: copySystemdFiles
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def copySystemdFiles():
# Delete any existing openvpn.service and copy openvpn service file to config directory
service_source = getAddonPath(True, "openvpn.service")
service_dest = getSystemdPath("system.d/openvpn.service")
debugTrace("Copying openvpn.service " + service_source + " to " + service_dest)
if not fakeSystemd():
if xbmcvfs.exists(service_dest): xbmcvfs.delete(service_dest)
xbmcvfs.copy(service_source, service_dest)
if not xbmcvfs.exists(service_dest): raise IOError('Failed to copy service ' + service_source + " to " + service_dest)
# Delete any existing openvpn.config and copy first VPN to openvpn.config
config_source = sudo_setting = xbmcaddon.Addon(getID()).getSetting("1_vpn_validated")
if service_source == "": errorTrace("vpnplatform.py", "Nothing has been validated")
config_dest = getSystemdPath("openvpn.config")
debugTrace("Copying openvpn.config " + config_source + " to " + config_dest)
if not fakeSystemd():
if xbmcvfs.exists(config_dest): xbmcvfs.delete(config_dest)
xbmcvfs.copy(config_source, config_dest)
if not xbmcvfs.exists(config_dest): raise IOError('Failed to copy service ovpn ' + config_source + " to " + config_dest)
示例4: copyUserDefinedFiles
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def copyUserDefinedFiles():
# Copy everything in the user directory to the addon directory
infoTrace("vpnproviders.py", "Copying user defined files from userdata directory")
source_path = getUserDataPath((user_def_str)+"/")
dest_path = getAddonPath(True, user_def_str + "/")
# Get the list of connection profiles and another list of strings to abuse for the selection screen
try:
files = getUserDataList(user_def_str, "*")
if len(files) == 0:
errorTrace("vpnproviders.py", "No User Defined files available to copy from " + source_path)
return False
for file in files:
name = file[file.rfind(getSeparator())+1:]
dest_file = dest_path + getSeparator() + name
xbmcvfs.copy(file, dest_file)
if not xbmcvfs.exists(dest_file): raise IOError('Failed to copy user def file ' + file + " to " + dest_file)
return True
except Exception as e:
errorTrace("vpnproviders.py", "Error copying files from " + source_path + " to " + dest_path)
errorTrace("vpnproviders.py", str(e))
return False
示例5: populateSupportingFromGit
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def populateSupportingFromGit(vpn_provider):
# Copy all files from download to the directory that are not .ovpn, ignoring the metadata
try:
filelist = getDownloadList(vpn_provider, "*")
debugTrace("Copying supporting files into addon directory for " + vpn_provider)
for file in filelist:
if not file.endswith(".ovpn") and not file.endswith("METADATA.txt"):
name = os.path.basename(file)
fullname = getAddonPath(True, vpn_provider + "/" + name)
xbmcvfs.copy(file, fullname)
if not xbmcvfs.exists(fullname): raise IOError('Failed to copy supporting file ' + file + " to " + fullname)
return True
except Exception as e:
errorTrace("vpnproviders.py", "Can't copy " + file + " for VPN " + vpn_provider)
errorTrace("vpnproviders.py", str(e))
return False
示例6: fix_update
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [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)
示例7: set_indx_properties
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def set_indx_properties(self, dictionary):
if not isinstance(dictionary, dict):
return
indxprops = set()
for k, v in dictionary.items():
if k in self.properties or k in _setprop_ratings or k in _setmain_artwork:
continue
try:
v = v or ''
self.set_property(k, v)
indxprops.add(k)
except Exception as exc:
utils.kodi_log(u'k: {0} v: {1} e: {2}'.format(k, v, exc), 1)
for k in (self.indxproperties - indxprops):
self.clear_property(k)
self.indxproperties = indxprops.copy()
示例8: _rotate_file
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def _rotate_file():
newdate = ndate = pykodi.get_infolabel('System.Date(yyyy-mm-dd)')
count = 0
while _exists(newdate):
count += 1
newdate = ndate + '.' + str(count)
if not xbmcvfs.copy(_get_filepath(), _get_filepath(newdate)):
log("Could not copy latest report to new filename", xbmc.LOGWARNING, 'reporting')
return False
if not xbmcvfs.delete(_get_filepath()):
log("Could not delete old copy of latest report", xbmc.LOGWARNING, 'reporting')
return False
# delete old reports
_, files = xbmcvfs.listdir(settings.datapath)
reportfiles = sorted(f[:-4] for f in files if f.startswith(REPORT_NAME))
while len(reportfiles) > REPORT_COUNT:
filename = reportfiles[0] + '.txt'
if not xbmcvfs.delete(settings.datapath + filename):
log("Could not delete old report '{0}'".format(filename), xbmc.LOGWARNING, 'reporting')
return False
del reportfiles[0]
report_startup()
return True
示例9: youtubeDLDownload
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def youtubeDLDownload(self,vid,path,target=None):
import YDStreamExtractor as StreamExtractor
import YDStreamUtils as StreamUtils
if not target: target = self.chooseDirectory()
if not target: return
with StreamUtils.DownloadProgress() as prog:
try:
StreamExtractor.disableDASHVideo(True)
StreamExtractor.setOutputCallback(prog)
result = StreamExtractor.downloadVideo(vid,path)
finally:
StreamExtractor.setOutputCallback(None)
if not result and result.status != 'canceled':
xbmcgui.Dialog().ok(T(32103),'[CR]',result.message)
elif result:
xbmcgui.Dialog().ok(T(32062),T(32104),'[CR]',result.filepath)
if target:
xbmcvfs.copy(result.filepath,os.path.join(target,os.path.basename(result.filepath)))
xbmcvfs.delete(result.filepath)
示例10: convert
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def convert(path):
input = xbmcvfs.File(path,'rb')
output = xbmcvfs.File(path.replace('.ts','.mp4'),'wb')
error = open(xbmc.translatePath("special://profile/addon_data/plugin.video.iptv.recorder/errors.txt"),"w")
cmd = [ffmpeg_location(),"-fflags","+genpts","-y","-i","-","-vcodec","copy","-acodec","copy","-f", "mpegts", "-"]
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=error, shell=windows())
t = threading.Thread(target=read_thread,args=[p,output])
t.start()
while True:
data = input.read(100000)
log(("read",len(data)))
if not data:
break
p.stdin.write(data)
p.stdin.close()
error.close()
示例11: copy
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def copy(src, dest):
"""Copy a file (using xbmcvfs)"""
from xbmcvfs import copy as vfscopy
log(2, "Copy file '{src}' to '{dest}'.", src=src, dest=dest)
return vfscopy(from_unicode(src), from_unicode(dest))
示例12: unzip_file
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def unzip_file(path, dest):
''' Unzip specific file. Path should start with zip://
'''
xbmcvfs.copy(path, dest)
LOG.debug("unzip: %s to %s", path, dest)
示例13: copy_file
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def copy_file(path, dest):
''' Copy specific file.
'''
if path.endswith('.pyo'):
return
xbmcvfs.copy(path, dest)
LOG.debug("copy: %s to %s", path, dest)
示例14: get_video_extras
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
def get_video_extras(item_id, path, server_id=None):
''' Returns the video files for the item as plugin listing, can be used
to browse actual files or video extras, etc.
'''
if not item_id and 'plugin.video.emby' in path:
item_id = path.split('/')[-2]
if not item_id:
return
get_server(server_id)
item = EMBY['api'].get_item(item_id)
# TODO
"""
def getVideoFiles(embyId,embyPath):
#returns the video files for the item as plugin listing, can be used for browsing the actual files or videoextras etc.
emby = embyserver.Read_EmbyServer()
if not embyId:
if "plugin.video.emby" in embyPath:
embyId = embyPath.split("/")[-2]
if embyId:
item = emby.getItem(embyId)
putils = playutils.PlayUtils(item)
if putils.isDirectPlay():
#only proceed if we can access the files directly. TODO: copy local on the fly if accessed outside
filelocation = putils.directPlay()
if not filelocation.endswith("/"):
filelocation = filelocation.rpartition("/")[0]
dirs, files = xbmcvfs.listdir(filelocation)
for file in files:
file = filelocation + file
li = xbmcgui.ListItem(file, path=file)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=file, listitem=li)
for dir in dirs:
dir = filelocation + dir
li = xbmcgui.ListItem(dir, path=dir)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=dir, listitem=li, isFolder=True)
#xbmcplugin.endOfDirectory(int(sys.argv[1]))
"""
示例15: ffmpeg_location
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import copy [as 別名]
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
if ffmpeg:
try:
st = os.stat(ffmpeg)
if not (st.st_mode & stat.S_IXUSR):
try:
os.chmod(ffmpeg, st.st_mode | stat.S_IXUSR)
except:
pass
except:
pass
if xbmcvfs.exists(ffmpeg):
return ffmpeg
else:
xbmcgui.Dialog().notification("TVGF", "ffmpeg exe not found!")