Example #1
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)
Example #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)
Example #3
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)