コード例 #1
0
ファイル: repo.py プロジェクト: sjanulonoks/packpack
 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'])
コード例 #2
0
def url_sibling(url, sibling):
    """
    Replaces the last path element in an url

    Parameters
    ----------
    url : str
        The url for which the last path element should be replaced
    sibling : str
        The replace value
    """
    parsed = urlparse(url)
    newpath_segments = pathsplit(parsed.path)[:-1] + (sibling, )
    newpath = pathjoin(*newpath_segments)
    return urlunparse(list(parsed[:2]) + [newpath] + list(parsed[3:]))
コード例 #3
0
ファイル: repo.py プロジェクト: sjanulonoks/packpack
    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)
コード例 #4
0
ファイル: lslog.py プロジェクト: kirin123kirin/cmd
def split_ls(
    line,
    parent=None,
    base_date=None,
    mod_sp = re.compile(" +")
    ):

    if line.startswith("l"):
        p, _, o, g, size, *d, name, _, ln = mod_sp.split(line)
    else:
        ln = ""
        p, _, o, g, size, *d, name = mod_sp.split(line)

    dt = to_datetime(" ".join(d))

    if base_date is None:
        base_date = datetime.now()
    elif isinstance(base_date, str):
        base_date = to_datetime(base_date)

    if dt > base_date:
        dt = dt.replace(year=base_date.year - 1)

    dt = dt.strftime("%Y/%m/%d"), dt.strftime("%H:%M:%S")

    try:
        size = int(size)
    except ValueError:
        pass

    ret = [p, o, g, size, *dt, name.split(".")[-1] if "." in name else "", name]

    if not parent or parent == ".":
        return [*ret, ln]

    parent = normpath(parent)
    fullpath = pathjoin(parent, name)
    diritem = (fullpath if p.startswith("d") else parent).strip("/").split("/")

    return [*ret, ln, fullpath, *map("/".__add__, diritem)]
コード例 #5
0
ファイル: rabbitmq.py プロジェクト: andyneff/voxel-globe
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'])
コード例 #6
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'
    ])
コード例 #7
0
ファイル: repo.py プロジェクト: sjanulonoks/packpack
 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"))