本文整理汇总了Python中exe.engine.path.Path.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Path.copy方法的具体用法?Python Path.copy怎么用?Python Path.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.path.Path
的用法示例。
在下文中一共展示了Path.copy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateIdevices
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copy [as 别名]
def updateIdevices(self):
"""
Update new style HTML/Javascript idevices in user directory.
Copy only when the files are newer
"""
idevice_src_dir=self.webDir/'templates'/'idevices'
idevice_dst_dir=self.configDir/"idevices"
for dir, subdirs, files in os.walk(idevice_src_dir):
reldirpath = idevice_src_dir.relpathto(dir)
for file in files:
dst_file = idevice_dst_dir/reldirpath/file
src_file = Path(dir)/file
src_mtime = src_file.mtime
if not dst_file.exists() or src_mtime > dst_file.mtime:
#check dir
if not dst_file.dirname().isdir():
dst_file.dirname().makedirs()
if file == "idevice.xml" and dst_file.exists():
#We need to update the file whilst preserving if it's visible or not....
dst_xml = etree.parse(dst_file).getroot()
ns = dst_xml.nsmap.get(None)
visible_val = dst_xml.find(".//{%s}visible" % ns).text
src_xml = etree.parse(src_file)
src_xml.find(".//{%s}visible" % ns).text = visible_val
dst_fd = open(dst_file, "w")
dst_fd.write(etree.tostring(src_xml, encoding = "UTF-8", pretty_print = True))
dst_fd.flush()
dst_fd.close()
else:
src_file.copy(dst_file)
示例2: main
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copy [as 别名]
def main():
if len(sys.argv) < 2:
print 'Usage: %s [version] [--install] [--local|username password]' % sys.argv[0]
print 'Where [version] is the branch you want to checkout'
print 'and username and password are for your eduforge account'
print 'Eg. %s 0.7 --local' % sys.argv[0]
else:
version = sys.argv[1]
branch = 'http://exe.cfdl.auckland.ac.nz/svn/exe/branches/%s' % version
origDir = Path(sys.argv[0]).abspath().dirname()
tmp = TempDirPath()
os.chdir(tmp)
os.system('svn export %s exe' % branch)
(origDir/'../../exe/webui/firefox').copytree(tmp/'exe/exe/webui/firefox')
os.chdir(tmp/'exe')
tarball = Path('../exe-%s-source.tgz' % version).abspath()
os.system('tar czf %s *' % tarball)
os.chdir(tmp)
if '--local' not in sys.argv:
try:
from paramiko import Transport
except ImportError:
print 'To upload you need to install paramiko python library from:'
print 'http://www.lag.net/paramiko'
sys.exit(2)
from socket import socket, gethostbyname
s = socket()
s.connect((gethostbyname('shell.eduforge.org'), 22))
t = Transport(s)
t.connect()
t.auth_password(sys.argv[-2], sys.argv[-1])
f = t.open_sftp_client()
f.chdir('/home/pub/exe')
f.put(tarball.encode('utf8'), tarball.basename().encode('utf8'))
if os.getuid() == 0:
tarball.copyfile('/usr/portage/distfiles/' + tarball.basename())
os.chdir(tmp/'exe/installs/gentoo')
newEbuildFilename = Path('exe-%s.ebuild' % version).abspath()
if not newEbuildFilename.exists():
Path('exe-0.7.ebuild').copy(newEbuildFilename)
if os.getuid() == 0:
ebuildDir = Path('/usr/local/portage/dev-python/exe')
if ebuildDir.exists():
ebuildDir.rmtree()
ebuildDir.makedirs()
os.chdir(ebuildDir)
newEbuildFilename.copy(ebuildDir)
filesDir = ebuildDir/'files'
filesDir.makedirs()
Path(tmp/'exe/installs/gentoo/all-config.patch').copy(filesDir)
if '--local' not in sys.argv:
oldTarball = Path('/usr/portage/distfiles/')/tarball.basename()
if oldTarball.exists():
oldTarball.remove()
os.environ['GENTOO_MIRRORS']=''
os.system('ebuild %s fetch' % newEbuildFilename.basename())
os.system('ebuild %s manifest' % newEbuildFilename.basename())
os.system('ebuild %s digest' % newEbuildFilename.basename())
if '--install' in sys.argv:
os.system('ebuild %s install' % newEbuildFilename.basename())
示例3: updateStyles
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copy [as 别名]
def updateStyles(self):
bkstyle=self.webDir/'style'
dststyle=self.stylesDir
for dir, subdirs, files in os.walk(bkstyle):
reldirpath = dir.relpathto(bkstyle)
for file in files:
dst_file = dststyle/reldirpath/file
src_file = Path(dir/file)
src_mtime = src_file.mtime
if not dst_file.exists() or src_mtime > dst_file.mtime:
src_file.copy(dst_file)
示例4: len
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copy [as 别名]
parser.error(_(u'No file input supplied.').encode(sys.stdout.encoding))
inputf = args[0]
try:
outputf = args[1]
except IndexError:
outputf = None
if len(args) > 2:
parser.error(_(u'Bad number of arguments supplied').encode(sys.stdout.encoding))
tempdir = TempDirPath()
if options.set_options:
try:
path = Path(inputf)
path.copy(tempdir)
inputf = tempdir / path.basename()
pkg = Package.load(inputf)
if not pkg:
error = _(u"Invalid input package")
raise Exception(error.encode(sys.stdout.encoding))
set_options = options.set_options.split(',')
for set_option in set_options:
name, value = set_option.split('=')
names = name.split('.')
obj = pkg
for name in names[:-1]:
obj = getattr(obj, name)
name = names[-1]
prop_type = type(getattr(obj, name))
示例5: loadSettings
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copy [as 别名]
def loadSettings(self):
"""
Loads the settings from the exe.conf file.
Overrides the defaults set in __init__
"""
# Set up the parser so that if a certain value is not in the config
# file, it will use the value from our default values
def defVal(dummy, option):
"""If something is not in the config file, just use the default in
'self'"""
return getattr(self, option)
self.configParser.defaultValue = defVal
self.upgradeFile()
# System Section
if self.configParser.has_section('system'):
system = self.configParser.system
self.port = int(system.port)
self.browser = None if system.browser == u"None" else system.browser
self.stylesRepository = system.stylesRepository
if not G.application.portable:
self.dataDir = Path(system.dataDir)
self.configDir = Path(system.configDir)
self.webDir = Path(system.webDir)
self.stylesDir = Path(self.configDir)/'style'
self.jsDir = Path(system.jsDir)
else:
self.stylesDir = Path(self.webDir/'style').abspath()
self.assumeMediaPlugins = False
if self.configParser.has_option('system', 'assumeMediaPlugins'):
value = system.assumeMediaPlugins.strip().lower()
if value == "1" or value == "yes" or value == "true" or value == "on":
self.assumeMediaPlugins = True
# If the dataDir points to some other dir, fix it
if not self.dataDir.isdir():
self.dataDir = tempfile.gettempdir()
# make the webDir absolute, to hide path joins of relative paths
self.webDir = self.webDir.expand().abspath()
# If the configDir doesn't exist (as it may be a default setting with a
# new installation) create it
if not self.configDir.exists():
self.configDir.mkdir()
if not G.application.standalone:
# FM: Copy styles
if not os.path.exists(self.stylesDir) or not os.listdir(self.stylesDir):
self.copyStyles()
else:
self.updateStyles()
else:
if G.application.portable:
if os.name == 'posix':
self.stylesDir = Path(self.webDir/'..'/'..'/'..'/'style')
else:
self.stylesDir = Path(self.webDir/'..'/'style')
if not os.path.exists(self.stylesDir) or not os.listdir(self.stylesDir):
self.copyStyles()
else:
self.stylesDir = Path(self.webDir/'style').abspath()
self.updateIdevices()
#copy the normal.epub template
normal_epub_src = Path(self.webDir/'templates'/'normal.epub')
normal_epub_src.copy(Path(self.configDir))
# Get the list of recently opened projects
self.recentProjects = []
if self.configParser.has_section('recent_projects'):
recentProjectsSection = self.configParser.recent_projects
# recentProjectsSection.items() is in the wrong order, keys are alright.
# Sorting list by key before adding to self.recentProjects, to avoid wrong ordering
# in Recent Projects menu list
recentProjectsItems = recentProjectsSection.items()
recentProjectsItems.sort()
for key, path in recentProjectsItems:
self.recentProjects.append(path)
# Load the list of "hidden" iDevices
self.hiddeniDevices = []
if self.configParser.has_section('idevices'):
idevicesSection = self.configParser.idevices
for key, value in idevicesSection.items():
# emulate standard library's getboolean()
value = value.strip().lower()
if value == "0" or value == "no" or value == "false" or \
value == "off":
self.hiddeniDevices.append(key.lower())
# self.deprecatediDevices = [ "flash with text", "flash movie", ...]
# and UN-Load from the list of "deprecated" iDevices
if self.configParser.has_section('deprecated'):
deprecatedSection = self.configParser.deprecated
for key, value in deprecatedSection.items():
# emulate standard library's getboolean()
value = value.strip().lower()
if value == "1" or value == "yes" or value == "true" or \
#.........这里部分代码省略.........