本文整理汇总了Python中pisi.uri.URI类的典型用法代码示例。如果您正苦于以下问题:Python URI类的具体用法?Python URI怎么用?Python URI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了URI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_spec_file
def set_spec_file(self, specuri):
if not specuri.is_remote_file():
specuri = URI(os.path.realpath(specuri.get_uri())) # FIXME: doesn't work for file://
self.specuri = specuri
spec = SpecFile()
spec.read(specuri, ctx.config.tmp_dir())
self.spec = spec
示例2: __init__
def __init__(self, specuri, authinfo = None):
# process args
if not isinstance(specuri, URI):
specuri = URI(specuri)
if authinfo:
specuri.set_auth_info(authinfo)
self.authinfo = authinfo
# read spec file, we'll need it :)
self.set_spec_file(specuri)
if specuri.is_remote_file():
#make local here and fuck up
self.specdir = self.fetch_files()
else:
self.specdir = dirname(self.specuri.get_uri())
self.sourceArchive = SourceArchive(self.spec, self.pkg_work_dir())
self.set_environment_vars()
self.actionLocals = None
self.actionGlobals = None
self.srcDir = None
示例3: prepare_for_build
def prepare_for_build(pspecfile, authInfo=None):
# FIXME: there is a function named "build" in this module which
# makes it impossible to use build module directly.
from build import PisiBuild
url = URI(pspecfile)
if url.is_remote_file():
from sourcefetcher import SourceFetcher
fs = SourceFetcher(url, authInfo)
url.uri = fs.fetch_all()
pb = PisiBuild(url.uri)
# find out the build dependencies that are not satisfied...
dep_unsatis = []
for dep in pb.spec.source.buildDeps:
if not dependency.installed_satisfies_dep(dep):
dep_unsatis.append(dep)
# FIXME: take care of the required buildDeps...
# For now just report an error!
if dep_unsatis:
ctx.ui.error(_("Unsatisfied Build Dependencies:"))
for dep in dep_unsatis:
ctx.ui.warning(dep.package)
# FIXME: Don't exit for now! It's annoying to test on a system that
# doesn't has all packages made with pisi.
# Will be enabled on the full-pisi system.
# sys.exit(1)
return pb
示例4: __init__
def __init__(self, packagefn, mode='r'):
self.filepath = packagefn
url = URI(packagefn)
if url.is_remote_file():
self.fetch_remote_file(url)
self.impl = archive.ArchiveZip(self.filepath, 'zip', mode)
示例5: __init__
def __init__(self, url, dest):
if not isinstance(url, URI):
url = URI(url)
self.scheme = url.scheme()
self.url = url
self.filedest = dest
util.check_dir(self.filedest)
self.percent = 0
self.rate = 0.0
self.progress = None
self.existsize = 0
示例6: install_single
def install_single(pkg, upgrade = False):
"""install a single package from URI or ID"""
url = URI(pkg)
# Check if we are dealing with a remote file or a real path of
# package filename. Otherwise we'll try installing a package from
# the package repository.
if url.is_remote_file() or os.path.exists(url.uri):
install_single_file(pkg, upgrade)
else:
install_single_name(pkg, upgrade)
示例7: prepare_for_build
def prepare_for_build(pspecfile, authInfo=None):
url = URI(pspecfile)
if url.is_remote_file():
from sourcefetcher import SourceFetcher
fs = SourceFetcher(url, authInfo)
url.uri = fs.fetch_all()
import pisi.build
pb = pisi.build.Builder(url.uri)
return pb
示例8: prepare_for_build
def prepare_for_build(pspecfile, authInfo=None):
# FIXME: there is a function named "build" in this module which
# makes it impossible to use build module directly.
from build import PisiBuild
url = URI(pspecfile)
if url.is_remote_file():
from sourcefetcher import SourceFetcher
fs = SourceFetcher(url, authInfo)
url.uri = fs.fetch_all()
pb = PisiBuild(url.uri)
return pb
示例9: __init__
def __init__(self, url, destdir, resume = True):
if not isinstance(url, URI):
url = URI(url)
self.resume = resume
self.scheme = url.scheme()
self.url = url
self.destdir = destdir
util.check_dir(self.destdir)
self.eta = '??:??:??'
self.percent = 0
self.rate = 0.0
self.progress = None
self.exist_size = 0
示例10: __init__
def __init__(self, bctx):
self.url = URI(bctx.spec.source.archiveUri)
self.archiveFile = join(ctx.config.archives_dir(), self.url.filename())
self.archiveName = bctx.spec.source.archiveName
self.archiveType = bctx.spec.source.archiveType
self.archiveSHA1 = bctx.spec.source.archiveSHA1
self.bctx = bctx
示例11: read_uri
def read_uri(self, filename, repo = None):
"""Read PSPEC file"""
self.filepath = filename
url = URI(filename)
if url.is_remote_file():
from fetcher import fetch_url
assert repo
dest = os.path.join(ctx.config.index_dir(), repo)
if not os.path.exists(dest):
os.makedirs(dest)
fetch_url(url, dest, ctx.ui.Progress)
self.filepath = os.path.join(dest, url.filename())
self.read(self.filepath)
示例12: __init__
class SourceArchive:
"""source archive. this is a class responsible for fetching
and unpacking a source archive"""
def __init__(self, spec, pkg_work_dir):
self.url = URI(spec.source.archive.uri)
self.pkg_work_dir = pkg_work_dir
self.archiveFile = join(ctx.config.archives_dir(), self.url.filename())
self.archive = spec.source.archive
def fetch(self, interactive=True):
if not self.is_cached(interactive):
if interactive:
progress = ctx.ui.Progress
else:
progress = None
try:
fetch_url(self.url, ctx.config.archives_dir(), progress)
except pisi.fetcher.FetchError:
# if archive can not be reached from the url, try the fallback
# address.
if ctx.config.values.build.fallback:
archive = basename(self.url.get_uri())
src = join(ctx.config.values.build.fallback, archive)
fetch_url(src, ctx.config.archives_dir(), progress)
else:
raise
def is_cached(self, interactive=True):
if not access(self.archiveFile, R_OK):
return False
# check hash
if util.check_file_hash(self.archiveFile, self.archive.sha1sum):
if interactive:
ctx.ui.info(_('%s [cached]') % self.archive.name)
return True
return False
def unpack(self, clean_dir=True):
# check archive file's integrity
if not util.check_file_hash(self.archiveFile, self.archive.sha1sum):
raise Error, _("unpack: check_file_hash failed")
archive = Archive(self.archiveFile, self.archive.type)
archive.unpack(self.pkg_work_dir, clean_dir)
示例13: rebuild_repo
def rebuild_repo(repo):
ctx.ui.info(_('* Rebuilding \'%s\' named repo... ') % repo)
if ctx.repodb.has_repo(repo):
repouri = URI(ctx.repodb.get_repo(repo).indexuri.get_uri())
indexname = repouri.filename()
index = Index()
indexpath = pisi.util.join_path(ctx.config.index_dir(), repo, indexname)
tmpdir = os.path.join(ctx.config.tmp_dir(), 'index')
pisi.util.clean_dir(tmpdir)
pisi.util.check_dir(tmpdir)
try:
index.read_uri(indexpath, tmpdir, force=True) # don't look for sha1sum there
except IOError, e:
ctx.ui.warning(_("Input/Output error while reading %s: %s") % (indexpath, unicode(e)))
return
ctx.txn_proc(lambda txn : index.update_db(repo, txn=txn))
示例14: __init__
def __init__(self, url, destdir, resume = True):
if not isinstance(url, URI):
url = URI(url)
if ctx.config.get_option("authinfo"):
url.set_auth_info(ctx.config.get_option("authinfo"))
self.resume = resume
self.scheme = url.scheme()
self.url = url
self.destdir = destdir
util.check_dir(self.destdir)
self.eta = '??:??:??'
self.percent = 0
self.rate = 0.0
self.progress = None
self.exist_size = 0
示例15: __init__
def __init__(self, packagefn, mode='r'):
self.filepath = packagefn
url = URI(packagefn)
if url.is_remote_file():
from fetcher import fetch_url
dest = ctx.config.packages_dir()
self.filepath = join(dest, url.filename())
# FIXME: exists is not enough, also sha1sum check needed \
# when implemented in pisi-index.xml
if not exists(self.filepath):
fetch_url(url, dest, ctx.ui.Progress)
else:
ctx.ui.info(_('%s [cached]') % url.filename())
self.impl = archive.ArchiveZip(self.filepath, 'zip', mode)