added command 'repolist'

This commit is contained in:
Dimitris Zlatanidis 2014-12-22 04:40:06 +02:00
parent ab4c3f42ad
commit 1c1a1f8f95
5 changed files with 89 additions and 9 deletions

View file

@ -23,7 +23,6 @@
import os
__all__ = "slpkg"
__author__ = "dslackw"
__version_info__ = (2, 1, 'x-dev')
@ -44,7 +43,7 @@ repositories = [
'slacky',
'studio',
'slackr',
'only'
'slonly'
]
build_path = "/tmp/slpkg/build/"
slpkg_tmp_packages = tmp + "slpkg/packages/"

View file

@ -21,6 +21,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
from __metadata__ import (
__version__,
@ -36,6 +37,7 @@ def options():
" update update all package " +
"lists",
" re-create recreate package lists",
" repolist list all repositories",
" update slpkg check and update slpkg\n",
"Optional arguments:",
" -h, --help show this help message " +
@ -68,6 +70,7 @@ def options():
]
for opt in arguments:
print(opt)
sys.exit(0)
def usage():
@ -89,3 +92,4 @@ def usage():
]
for usg in view:
print(usg)
sys.exit(0)

View file

@ -24,6 +24,8 @@
import sys
import getpass
from repolist import RepoList
from desc import PkgDesc
from config import Config
from queue import QueuePkgs
@ -126,21 +128,26 @@ def main():
if len(args) == 2 and args[0] == "update" and args[1] == "slpkg":
it_self_update()
# checking if repositories exists
check_exists_repositories()
if len(args) == 1 and args[0] == "re-create":
Initialization().re_create()
if len(args) == 1 and args[0] == "repolist":
RepoList().repos()
if len(args) == 0:
usage()
elif (len(args) == 1 and args[0] == "-h" or
args[0] == "--help" and args[1:] == []):
options()
elif (len(args) == 1 and args[0] == "-v" or
if (len(args) == 1 and args[0] == "-v" or
args[0] == "--version" and args[1:] == []):
prog_version()
elif len(args) == 3 and args[0] == "-a":
# checking if repositories exists
check_exists_repositories()
if len(args) == 1 and args[0] == "re-create":
Initialization().re_create()
if len(args) == 3 and args[0] == "-a":
BuildPackage(args[1], args[2:], path).build()
elif len(args) == 2 and args[0] == "-l":
pkg_list = ["all", "noarch"] + repositories

67
slpkg/repolist.py Normal file
View file

@ -0,0 +1,67 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# repolist.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Slpkg is a user-friendly package manager for Slackware installations
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
from repositories import Repo
from messages import template
from __metadata__ import repositories, color
class RepoList(object):
def __init__(self):
self.all_repos = {
'slack': Repo().slack(),
'sbo': Repo().sbo(),
'rlw': Repo().rlw(),
'alien': Repo().alien(),
'slacky': Repo().slacky(),
'studio': Repo().studioware(),
'slackr': Repo().slackers(),
'slonly': Repo().slackonly()
}
def repos(self):
'''
View or enabled or disabled repositories
'''
print('')
template(78)
print('{0}{1}{2}{3}{4}'.format(
'| Repo id', ' ' * 10,
'Repo name', ' ' * 45,
'Status'))
template(78)
for repo_id, repo_name in sorted(self.all_repos.iteritems()):
status = '{0}disabled{1}'.format(color['RED'], color['ENDC'])
if repo_id in repositories:
status = '{0}enabled{1}'.format(color['GREEN'], color['ENDC'])
print(' {0}{1}{2}{3}{4:>17}'.format(
repo_id, ' ' * (17 - len(repo_id)),
repo_name, ' ' * (52 - len(repo_name)),
status))
print("\nFor enable or disable repositories edit "
"'/etc/slpkg/slpkg.conf' file\n")
sys.exit(0)

View file

@ -21,6 +21,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
from __metadata__ import (
__version__,
__license__,
@ -35,3 +37,4 @@ def prog_version():
print("Version : {0}".format(__version__))
print("Licence : {0}".format(__license__))
print("Email : {0}".format(__email__))
sys.exit(0)