def get_file(url, local, opts, config): if local is None: raise error.general("source/patch path invalid") if not path.isdir(path.dirname(local)) and not opts.download_disabled(): log.notice("Creating source directory: %s" % (os.path.relpath(path.host(path.dirname(local))))) log.output("making dir: %s" % (path.host(path.dirname(local)))) if not opts.dry_run(): path.mkdir(path.dirname(local)) if not path.exists(local) and opts.download_disabled(): raise error.general("source not found: %s" % (path.host(local))) # # Check if a URL has been provided on the command line. # url_bases = opts.urls() urls = [] if url_bases is not None: for base in url_bases: if base[-1:] != "/": base += "/" url_path = urlparse.urlsplit(url)[2] slash = url_path.rfind("/") if slash < 0: url_file = url_path else: url_file = url_path[slash + 1 :] urls.append(urlparse.urljoin(base, url_file)) urls += url.split() log.trace("_url: %s -> %s" % (",".join(urls), local)) for url in urls: for dl in downloaders: if url.startswith(dl): if downloaders[dl](url, local, config, opts): return if not opts.dry_run(): raise error.general("downloading %s: all paths have failed, giving up" % (url))
def get_file(url, local, opts, config): if local is None: raise error.general('source/patch path invalid') if not path.isdir(path.dirname(local)) and not opts.download_disabled(): log.notice('Creating source directory: %s' % \ (os.path.relpath(path.host(path.dirname(local))))) log.output('making dir: %s' % (path.host(path.dirname(local)))) if _do_download(opts): path.mkdir(path.dirname(local)) if not path.exists(local) and opts.download_disabled(): raise error.general('source not found: %s' % (path.host(local))) # # Check if a URL has been provided on the command line. If the package is # release push to the start the RTEMS URL. # url_bases = opts.urls() if version.released(): rtems_release_url = config.macros.expand('%{rtems_release_url}/%{rsb_version}/sources') log.trace('release url: %s' % (rtems_release_url)) # # If the URL being fetched is under the release path do not add the # sources release path because it is already there. # if not url.startswith(rtems_release_url): if url_bases is None: url_bases = [rtems_release_url] else: url_bases.append(rtems_release_url) urls = [] if url_bases is not None: # # Split up the URL we are being asked to download. # url_path = urlparse.urlsplit(url)[2] slash = url_path.rfind('/') if slash < 0: url_file = url_path else: url_file = url_path[slash + 1:] log.trace('url_file: %s' %(url_file)) for base in url_bases: if base[-1:] != '/': base += '/' next_url = urlparse.urljoin(base, url_file) log.trace('url: %s' %(next_url)) urls.append(next_url) urls += url.split() log.trace('_url: %s -> %s' % (','.join(urls), local)) for url in urls: for dl in downloaders: if url.startswith(dl): if downloaders[dl](url, local, config, opts): return if _do_download(opts): raise error.general('downloading %s: all paths have failed, giving up' % (url))
def bset_tar(self, _build): tardir = _build.config.expand('%{_tardir}') if self.opts.get_arg('--bset-tar-file') \ and not _build.macros.get('%{_disable_packaging}'): path.mkdir(tardir) tar = path.join(tardir, _build.config.expand('%s.tar.bz2' % (self.bset_pkg))) log.notice('tarball: %s' % (os.path.relpath(path.host(tar)))) if not self.opts.dry_run(): tmproot = _build.config.expand('%{_tmproot}') cmd = _build.config.expand("'cd " + tmproot + \ " && %{__tar} -cf - . | %{__bzip2} > " + tar + "'") _build.run(cmd, shell_opts = '-c', cwd = tmproot)
def bset_tar(self, _build): tardir = _build.config.expand("%{_tardir}") if (self.opts.get_arg("--bset-tar-file") or self.opts.canadian_cross()) and not _build.macros.get( "%{_disable_packaging}" ): path.mkdir(tardir) tar = path.join(tardir, _build.config.expand("%s.tar.bz2" % (self.bset_pkg))) log.notice("tarball: %s" % (os.path.relpath(path.host(tar)))) if not self.opts.dry_run(): tmproot = _build.config.expand("%{_tmproot}") cmd = _build.config.expand("'cd " + tmproot + " && %{__tar} -cf - . | %{__bzip2} > " + tar + "'") _build.run(cmd, shell_opts="-c", cwd=tmproot)
def bset_tar(self, _build): tardir = _build.config.expand('%{_tardir}') if (self.opts.get_arg('--bset-tar-file') or self.opts.canadian_cross()) \ and not _build.macros.get('%{_disable_packaging}'): path.mkdir(tardir) tar = path.join(tardir, _build.config.expand('%s.tar.bz2' % (_build.main_package().name()))) log.notice('tarball: %s' % (os.path.relpath(path.host(tar)))) if not self.opts.dry_run(): tmproot = _build.config.expand('%{_tmproot}') cmd = _build.config.expand('"cd ' + tmproot + \ ' && %{__tar} -cf - . | %{__bzip2} > ' + tar + '"') _build.run(cmd, shell_opts = '-c', cwd = tmproot)
def bset_tar(self, _build): tardir = _build.config.expand('%{_tardir}') if self.opts.get_arg('--bset-tar-file') \ and not _build.macros.get('%{_disable_packaging}'): path.mkdir(tardir) tar = path.join( tardir, _build.config.expand('%s.tar.bz2' % (self.bset_pkg))) log.notice('tarball: %s' % (os.path.relpath(path.host(tar)))) if not self.opts.dry_run(): tmproot = _build.config.expand('%{_tmproot}') cmd = _build.config.expand("'cd " + tmproot + \ " && %{__tar} -cf - . | %{__bzip2} > " + tar + "'") _build.run(cmd, shell_opts='-c', cwd=tmproot)
def _cvs_downloader(url, local, config, opts): rlp = os.path.relpath(path.host(local)) us = url.split('?') module = None tag = None date = None src_prefix = None for a in us[1:]: _as = a.split('=') if _as[0] == 'module': if len(_as) != 2: raise error.general('invalid cvs module: %s' % (a)) module = _as[1] elif _as[0] == 'src-prefix': if len(_as) != 2: raise error.general('invalid cvs src-prefix: %s' % (a)) src_prefix = _as[1] elif _as[0] == 'tag': if len(_as) != 2: raise error.general('invalid cvs tag: %s' % (a)) tag = _as[1] elif _as[0] == 'date': if len(_as) != 2: raise error.general('invalid cvs date: %s' % (a)) date = _as[1] repo = cvs.repo(local, opts, config.macros, src_prefix) if not repo.valid(): if not path.isdir(local): log.notice('Creating source directory: %s' % \ (os.path.relpath(path.host(local)))) if _do_download(opts): path.mkdir(local) log.notice('cvs: checkout: %s -> %s' % (us[0], rlp)) if _do_download(opts): repo.checkout(':%s' % (us[0][6:]), module, tag, date) for a in us[1:]: _as = a.split('=') if _as[0] == 'update': log.notice('cvs: update: %s' % (us[0])) if _do_download(opts): repo.update() elif _as[0] == 'reset': log.notice('cvs: reset: %s' % (us[0])) if _do_download(opts): repo.reset() return True
def _cvs_downloader(url, local, config, opts): rlp = os.path.relpath(path.host(local)) us = url.split("?") module = None tag = None date = None src_prefix = None for a in us[1:]: _as = a.split("=") if _as[0] == "module": if len(_as) != 2: raise error.general("invalid cvs module: %s" % (a)) module = _as[1] elif _as[0] == "src-prefix": if len(_as) != 2: raise error.general("invalid cvs src-prefix: %s" % (a)) src_prefix = _as[1] elif _as[0] == "tag": if len(_as) != 2: raise error.general("invalid cvs tag: %s" % (a)) tag = _as[1] elif _as[0] == "date": if len(_as) != 2: raise error.general("invalid cvs date: %s" % (a)) date = _as[1] repo = cvs.repo(local, opts, config.macros, src_prefix) if not repo.valid(): if not path.isdir(local): log.notice("Creating source directory: %s" % (os.path.relpath(path.host(local)))) if not opts.dry_run(): path.mkdir(local) log.notice("cvs: checkout: %s -> %s" % (us[0], rlp)) if not opts.dry_run(): repo.checkout(":%s" % (us[0][6:]), module, tag, date) for a in us[1:]: _as = a.split("=") if _as[0] == "update": log.notice("cvs: update: %s" % (us[0])) if not opts.dry_run(): repo.update() elif _as[0] == "reset": log.notice("cvs: reset: %s" % (us[0])) if not opts.dry_run(): repo.reset() return True
def __init__(self, infile, outdir): self.infile = infile self.outdir = outdir if not path.exists(outdir): path.mkdir(outdir) self.mobi7dir = os.path.join(outdir,'mobi7') if not path.exists(self.mobi7dir): path.mkdir(self.mobi7dir) self.imgdir = os.path.join(self.mobi7dir, 'Images') if not path.exists(self.imgdir): path.mkdir(self.imgdir) self.hdimgdir = os.path.join(outdir,'HDImages') if not path.exists(self.hdimgdir): path.mkdir(self.hdimgdir) self.outbase = os.path.join(outdir, os.path.splitext(os.path.split(infile)[1])[0])
def get_file(url, local, opts, config): if local is None: raise error.general('source/patch path invalid') if not path.isdir(path.dirname(local)) and not opts.download_disabled(): log.notice('Creating source directory: %s' % \ (os.path.relpath(path.host(path.dirname(local))))) log.output('making dir: %s' % (path.host(path.dirname(local)))) if _do_download(opts): path.mkdir(path.dirname(local)) if not path.exists(local) and opts.download_disabled(): raise error.general('source not found: %s' % (path.host(local))) # # Check if a URL has been provided on the command line. # url_bases = opts.urls() urls = [] if url_bases is not None: for base in url_bases: if base[-1:] != '/': base += '/' url_path = urlparse.urlsplit(url)[2] slash = url_path.rfind('/') if slash < 0: url_file = url_path else: url_file = url_path[slash + 1:] urls.append(urlparse.urljoin(base, url_file)) urls += url.split() log.trace('_url: %s -> %s' % (','.join(urls), local)) for url in urls: for dl in downloaders: if url.startswith(dl): if downloaders[dl](url, local, config, opts): return if _do_download(opts): raise error.general( 'downloading %s: all paths have failed, giving up' % (url))
def __init__(self, infile, outdir): self.infile = infile self.outdir = outdir if not path.exists(outdir): path.mkdir(outdir) self.mobi7dir = os.path.join(outdir, 'mobi7') if not path.exists(self.mobi7dir): path.mkdir(self.mobi7dir) self.imgdir = os.path.join(self.mobi7dir, 'Images') if not path.exists(self.imgdir): path.mkdir(self.imgdir) self.hdimgdir = os.path.join(outdir, 'HDImages') if not path.exists(self.hdimgdir): path.mkdir(self.hdimgdir) self.outbase = os.path.join( outdir, os.path.splitext(os.path.split(infile)[1])[0])
if keys[l[0]] not in _status: _status[keys[l[0]]] = [] _status[keys[l[0]]] += [l[2:]] return _status def clean(self): _status = self.status() return len(_status) == 0 def valid(self): if path.exists(self.path): ec, output = self._run(['-n', 'up', '-l']) if ec == 0: if not output.startswith('cvs status: No CVSROOT specified'): return True return False if __name__ == '__main__': import sys opts = options.load(sys.argv, defaults = 'defaults.mc') ldir = 'cvs-test-rm-me' c = repo(ldir, opts) if not path.exists(ldir): path.mkdir(ldir) c.checkout(':pserver:[email protected]:/cvs/src', module = 'newlib') print c.cvs_version() print c.valid() print c.status() c.reset() print c.clean()
def makeK8Struct(self): outdir = self.outdir self.k8dir = os.path.join(self.outdir,'mobi8') if not path.exists(self.k8dir): path.mkdir(self.k8dir) self.k8metainf = os.path.join(self.k8dir,'META-INF') if not path.exists(self.k8metainf): path.mkdir(self.k8metainf) self.k8oebps = os.path.join(self.k8dir,'OEBPS') if not path.exists(self.k8oebps): path.mkdir(self.k8oebps) self.k8images = os.path.join(self.k8oebps,'Images') if not path.exists(self.k8images): path.mkdir(self.k8images) self.k8fonts = os.path.join(self.k8oebps,'Fonts') if not path.exists(self.k8fonts): path.mkdir(self.k8fonts) self.k8styles = os.path.join(self.k8oebps,'Styles') if not path.exists(self.k8styles): path.mkdir(self.k8styles) self.k8text = os.path.join(self.k8oebps,'Text') if not path.exists(self.k8text): path.mkdir(self.k8text)
def get_file(url, local, opts, config): if local is None: raise error.general('source/patch path invalid') if not path.isdir(path.dirname(local)) and not opts.download_disabled(): log.notice('Creating source directory: %s' % \ (os.path.relpath(path.host(path.dirname(local))))) log.output('making dir: %s' % (path.host(path.dirname(local)))) if _do_download(opts): path.mkdir(path.dirname(local)) if not path.exists(local) and opts.download_disabled(): raise error.general('source not found: %s' % (path.host(local))) # # Check if a URL has been provided on the command line. If the package is # released push to the start the RTEMS URL unless overrided by the command # line option --with-release-url. The variant --without-release-url can # override the released check. # url_bases = opts.urls() try: rtems_release_url_value = config.macros.expand('%{rtems_release_url}/%{rsb_version}/sources') except: rtems_release_url_value = None log.output('RTEMS release URL could not be expanded') rtems_release_url = None if version.released() and rtems_release_url_value: rtems_release_url = rtems_release_url_value with_rel_url = opts.with_arg('release-url') if with_rel_url[1] == 'not-found': if config.defined('without_release_url'): with_rel_url = ('without_release-url', 'yes') if with_rel_url[0] == 'with_release-url': if with_rel_url[1] == 'yes': if rtems_release_url_value is None: raise error.general('no valid release URL') rtems_release_url = rtems_release_url_value elif with_rel_url[1] == 'no': pass else: rtems_release_url = with_rel_url[1] elif with_rel_url[0] == 'without_release-url' and with_rel_url[1] == 'yes': rtems_release_url = None if rtems_release_url is not None: log.trace('release url: %s' % (rtems_release_url)) # # If the URL being fetched is under the release path do not add the # sources release path because it is already there. # if not url.startswith(rtems_release_url): if url_bases is None: url_bases = [rtems_release_url] else: url_bases.append(rtems_release_url) urls = [] if url_bases is not None: # # Split up the URL we are being asked to download. # url_path = urllib_parse.urlsplit(url)[2] slash = url_path.rfind('/') if slash < 0: url_file = url_path else: url_file = url_path[slash + 1:] log.trace('url_file: %s' %(url_file)) for base in url_bases: if base[-1:] != '/': base += '/' next_url = urllib_parse.urljoin(base, url_file) log.trace('url: %s' %(next_url)) urls.append(next_url) urls += url.split() log.trace('_url: %s -> %s' % (','.join(urls), local)) for url in urls: for dl in downloaders: if url.startswith(dl): if downloaders[dl](url, local, config, opts): return if _do_download(opts): raise error.general('downloading %s: all paths have failed, giving up' % (url))
def mkdir(self, mkpath): log.output('making dir: %s' % (path.host(mkpath))) if not self.opts.dry_run(): path.mkdir(mkpath)
from pytube import YouTube import path import exceptions import os import res_fps print("Paste video URL:") URL = input() print("Please wait...") try: yt = YouTube(URL) except: exceptions.check(URL) #resval,fpsval = res(yt) resval = res_fps.res(yt) video = yt.streams.filter(file_extension="mp4", resolution=resval).first() path = path.mkdir(yt) if (path == "already exits"): exit() if (video.download(path)): print("\nDownload success!!!\n") else: print("An unfortunate error has occured...\n")
def makeK8Struct(self): outdir = self.outdir self.k8dir = os.path.join(self.outdir, 'mobi8') if not path.exists(self.k8dir): path.mkdir(self.k8dir) self.k8metainf = os.path.join(self.k8dir, 'META-INF') if not path.exists(self.k8metainf): path.mkdir(self.k8metainf) self.k8oebps = os.path.join(self.k8dir, 'OEBPS') if not path.exists(self.k8oebps): path.mkdir(self.k8oebps) self.k8images = os.path.join(self.k8oebps, 'Images') if not path.exists(self.k8images): path.mkdir(self.k8images) self.k8fonts = os.path.join(self.k8oebps, 'Fonts') if not path.exists(self.k8fonts): path.mkdir(self.k8fonts) self.k8styles = os.path.join(self.k8oebps, 'Styles') if not path.exists(self.k8styles): path.mkdir(self.k8styles) self.k8text = os.path.join(self.k8oebps, 'Text') if not path.exists(self.k8text): path.mkdir(self.k8text)