Esempio n. 1
0
 def load(self, path):
     '''Load a L{Package} object from a path to a package distribution.
     
     @return: the Distribution object.
     '''
     pkg = Package()
     pkg.installed_path = path 
     metadata_path = os.path.join(path, self.metadata_filename)
     fo = open(metadata_path)
     metadata = json.load(fo)
     readme_notes = self._get_notes_from_readme(path)
     if readme_notes:
         metadata['notes'] = readme_notes
     pkg.update_metadata(metadata)
     fo.close()
     return self(pkg)
Esempio n. 2
0
def push_all():
    current_dir = os.path.abspath('.')
    pkg = Package.load(current_dir)
    # load .dpm/config and
    cfgpath = os.path.join(current_dir, '.dpm/config')
    if not os.path.exists(cfgpath):
        msg = 'No .dpm/config file found. push only works with source packages.'
        logger.error(msg)
        raise Exception(msg)
    cfg = SafeConfigParser() 
    cfg.read(cfgpath)
    # get remote URL
    remote_url = cfg.get('remote', 'url')
    remote_url = remote_url.rstrip('/')
    remote_webstore_url = cfg.get('remote', 'webstore')
    
    for resource in pkg.resources:
        local_path = resource.get('local_path', '')
        if not local_path:
            continue
        mimetype = mimetypes.guess_type(local_path)[0]
        if mimetype not in webstorable_mimetypes:
            logger.info('Skipping %s as not webstorable' % local_path)
            continue
        # webstore_url = resource.get('webstore_url', '')
        fn = os.path.splitext(os.path.basename(local_path))[0]
        webstore_url = remote_webstore_url + '/' + fn
        push_file(local_path, webstore_url)
Esempio n. 3
0
 def load(self, path):
     '''Load a L{Package} object from a path to a package distribution.
     
     @return: the Distribution object.
     '''
     pkg = Package()
     pkg.installed_path = path
     metadata_path = os.path.join(path, self.metadata_filename)
     fo = open(metadata_path)
     metadata = json.load(fo)
     readme_notes = self._get_notes_from_readme(path)
     if readme_notes:
         metadata['notes'] = readme_notes
     pkg.update_metadata(metadata)
     fo.close()
     return self(pkg)
Esempio n. 4
0
 def get(self, name):
     if not name in self:
         msg = 'No package in %s with name %s. Have you registered/installed it?' % (
             self, name)
         raise DatapkgException(msg)
     path = os.path.join(self.index_path, name)
     return Package.load(path)
Esempio n. 5
0
 def setUp(self):
     self.tmpdir = self.make_tmpdir()
     self.installdir = os.path.join(self.tmpdir, 'installed')
     self.loaddir = os.path.join(self.tmpdir, 'load')
     os.makedirs(self.loaddir)
     self.pkg_name = 'mytestpkg'
     self.pkg = Package(name=self.pkg_name, version='1.0')
     self.dist = JsonDistribution(self.pkg)
Esempio n. 6
0
 def get(self, name):
     if not name in self:
         msg = 'No package in %s with name %s. Have you registered/installed it?' % (self, name)
         raise DatapkgException(msg)
     path = os.path.join(self.index_path, name)
     return Package.load(path)