Example #1
0
 def prune_repo(self, repo, kind):
     """
     Get all packages list in repo and prune old versions
     """
     path = pathjoin(
         "api", "v1", "repos", self.api_user,
         repo, "packages", "{}.json?per_page=500".format(kind)
     )
     packages = self.get(path)
     for package in packages:
         name = package['name']
         self.prune_versions(repo, name, package['versions_url'])
Example #2
0
    def prune_versions(self, repo, name, path):
        """
        Get package versions list and delete
        old versions up to versions_limit
        """
        versions = sorted(
            self.get(path),
            key=lambda v: v['created_at']
        )

        for version in versions[:-self.version_limit]:
            distro_version = version["distro_version"]
            filename = version["filename"]
            pkgpath = pathjoin(
                "api", "v1", "repos", self.api_user, repo,
                distro_version, filename
            )
            self.prune_package(name, pkgpath)
Example #3
0
from simple import Simple
from os import environ as env
from posixpath import join as pathjoin
import shlex
import os

if __name__=='__main__':
  env['RABBITMQ_BASE']=env['VIP_PROJECT_ROOT']
  env['RABBITMQ_LOG_BASE']=env['VIP_RABBITMQ_LOG_DIR']
  env['RABBITMQ_MNESIA_BASE']=env['VIP_RABBITMQ_MNESIA_BASE']
  env['HOMEDRIVE']=env['VIP_RABBITMQ_BASE_DRIVE']
  env['HOMEPATH']=env['VIP_RABBITMQ_BASE_PATH']
  env['RABBITMQ_PID_FILE']=env['VIP_RABBITMQ_PID_FILE']
  env['ERLANG_HOME']=env['VIP_RABBITMQ_ERLANG_HOME']
  
  if not os.path.exists(env['VIP_RABBITMQ_LOG_DIR']):
    os.mkdir(env['VIP_RABBITMQ_LOG_DIR']);
    
  Simple().run(['-o', pathjoin(env['VIP_RABBITMQ_LOG_DIR'], 'rabbitmq_out.log'),
                '-e', pathjoin(env['VIP_RABBITMQ_LOG_DIR'], 'rabbitmq_err.log'),
                '-p', pathjoin(env['VIP_INIT_DIR'], 'rabbitmq.pid'),
                'rabbitmq-server.bat'])
Example #4
0
 def __init__(self, token, user=API_USER, url=API_URL, limit=2):
     self.api_url = url
     self.auth = (token, '')
     self.api_user = user
     self.version_limit = limit
     self.repos = self.get(pathjoin("api", "v1", "repos"))