mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-29 20:34:22 +01:00
added command 'repoinfo'
This commit is contained in:
parent
3d60df923b
commit
d551309381
5 changed files with 111 additions and 0 deletions
|
@ -210,6 +210,8 @@ Command Line Tool Usage
|
|||
Commands:
|
||||
update update all package lists
|
||||
re-create recreate package lists
|
||||
repolist list all repositories
|
||||
repoinfo [repository] repository information
|
||||
update slpkg check and update slpkg
|
||||
|
||||
Optional arguments:
|
||||
|
|
|
@ -39,6 +39,7 @@ Commands:
|
|||
update update all package lists
|
||||
re-create recreate package lists
|
||||
repolist list all repositories
|
||||
repoinfo [repository] repository information
|
||||
update slpkg check and update slpkg
|
||||
|
||||
Optional arguments:
|
||||
|
@ -104,6 +105,11 @@ command deletes all the packages lists and re-created.
|
|||
.PP
|
||||
Lists all enabled or disabled repositories.
|
||||
|
||||
.SS repoinfo
|
||||
\fBslpkg\fP \fBrepoinfo\fP <\fBrepository\fP>
|
||||
.PP
|
||||
View repository information.
|
||||
|
||||
.SS update slpkg
|
||||
\fBslpkg\fP \fBupdate\fP \fBslpkg\fP
|
||||
.PP
|
||||
|
|
|
@ -38,6 +38,7 @@ def options():
|
|||
"lists",
|
||||
" re-create recreate package lists",
|
||||
" repolist list all repositories",
|
||||
" repoinfo [repository] repository information",
|
||||
" update slpkg check and update slpkg\n",
|
||||
"Optional arguments:",
|
||||
" -h, --help show this help message " +
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
import sys
|
||||
import getpass
|
||||
|
||||
from repoinfo import RepoInfo
|
||||
from repolist import RepoList
|
||||
|
||||
from desc import PkgDesc
|
||||
|
@ -131,6 +132,10 @@ def main():
|
|||
if len(args) == 1 and args[0] == "repolist":
|
||||
RepoList().repos()
|
||||
|
||||
if (len(args) == 2 and args[0] == "repoinfo" and
|
||||
args[1] in RepoList().all_repos):
|
||||
RepoInfo().view(args[1])
|
||||
|
||||
if len(args) == 0:
|
||||
usage()
|
||||
elif (len(args) == 1 and args[0] == "-h" or
|
||||
|
|
97
slpkg/repoinfo.py
Normal file
97
slpkg/repoinfo.py
Normal file
|
@ -0,0 +1,97 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# repoinfo.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 sizes import units
|
||||
from repolist import RepoList
|
||||
from __metadata__ import (
|
||||
lib_path,
|
||||
log_path,
|
||||
repositories,
|
||||
color
|
||||
)
|
||||
|
||||
|
||||
class RepoInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.form = {}
|
||||
self.all_repos = RepoList().all_repos
|
||||
del RepoList().all_repos
|
||||
|
||||
def view(self, repo):
|
||||
'''
|
||||
View repository information
|
||||
'''
|
||||
status = '{0}disabled{1}'.format(color['RED'], color['ENDC'])
|
||||
if repo in repositories:
|
||||
status = '{0}enabled{1}'.format(color['GREEN'], color['ENDC'])
|
||||
if repo != 'sbo':
|
||||
data = self.repository_data(repo)
|
||||
size = units(data[1], data[2])
|
||||
self.form['Repo id:'] = repo
|
||||
self.form['Repo url:'] = self.all_repos[repo]
|
||||
self.form['Total compressed packages:'] = '{0} {1}'.format(
|
||||
str(size[1][0]), str(size[0][0]))
|
||||
self.form['Total uncompressed packages:'] = '{0} {1}'.format(
|
||||
str(size[1][1]), str(size[0][1]))
|
||||
self.form['Number of packages:'] = data[0]
|
||||
self.form['Status:'] = status
|
||||
self.form['Last updated:'] = data[3]
|
||||
elif repo == 'sbo':
|
||||
sum_sbo_pkgs = 0
|
||||
for line in open(lib_path + 'sbo_repo/SLACKBUILDS.TXT', 'r'):
|
||||
if line.startswith('SLACKBUILD NAME: '):
|
||||
sum_sbo_pkgs += 1
|
||||
with open(log_path + 'sbo/ChangeLog.txt', 'r') as changelog_txt:
|
||||
last_upd = changelog_txt.readline().replace('\n', '')
|
||||
self.form['Repo id:'] = repo
|
||||
self.form['Repo url:'] = self.all_repos[repo]
|
||||
self.form['Total compressed packages:'] = ''
|
||||
self.form['Total uncompressed packages:'] = ''
|
||||
self.form['Number of packages:'] = sum_sbo_pkgs
|
||||
self.form['Status:'] = status
|
||||
self.form['Last updated:'] = last_upd
|
||||
print('')
|
||||
for key, value in sorted(self.form.iteritems()):
|
||||
print color['GREY'] + key + color['ENDC'], value
|
||||
print('')
|
||||
sys.exit(0)
|
||||
|
||||
def repository_data(self, repo):
|
||||
'''
|
||||
Grap data packages
|
||||
'''
|
||||
sum_pkgs, size, unsize, last_upd = 0, [], [], ''
|
||||
for line in open(lib_path + repo + '_repo/PACKAGES.TXT', 'r'):
|
||||
if line.startswith('PACKAGES.TXT;'):
|
||||
last_upd = line[14:].strip()
|
||||
if line.startswith('PACKAGE NAME:'):
|
||||
sum_pkgs += 1
|
||||
if line.startswith('PACKAGE SIZE (compressed): '):
|
||||
size.append(line[28:-2].strip())
|
||||
if line.startswith('PACKAGE SIZE (uncompressed): '):
|
||||
unsize.append(line[30:-2].strip())
|
||||
return [sum_pkgs, size, unsize, last_upd]
|
Loading…
Add table
Reference in a new issue