Updated for repo-enable coomand

This commit is contained in:
Dimitris Zlatanidis 2015-08-31 23:27:06 +03:00
parent c46175f7cd
commit 443068b9f6
7 changed files with 98 additions and 16 deletions

View file

@ -1,9 +1,13 @@
2.7.7 - 30/08/2015
2.7.7 - 31/08/2015
Added:
- NEW configuration file for repositories in /etc/slpkg/repositories.conf
- Enable and disable repositories with command via dialog utility
Update:
- Command line help logo
- Flags for packages upgrade
- Clear screen after exit dialog utility
Fixed:
- Remove None type packages
2.7.6 - 28/08/2015
Fixed:

9
KNOWN_ISSUES Normal file
View file

@ -0,0 +1,9 @@
Known issues:
- Dialog utility crash in option --buildlist when move with arrows
sometimes without yet that create big issues.
Issues reference here:
https://sourceforge.net/p/pythondialog/bugs/6/
Upgrade dialog utility from here if only necessary:
https://github.com/dslackw/slacks/tree/master/dialog

View file

@ -196,7 +196,7 @@ choices such read, download, build, install etc.
If you want to find packages from all repositories, this command will solve your hands '$ slpkg -F
<packages>'. It will search in all enabled repositories will find the configuration file
'/etc/slpkg/slpkg.conf' will print all the packages that match the description that you enter.
'/etc/slpkg/repositories.conf' will print all the packages that match the description that you enter.
If you want to see if any packages are installed on your system enter the command '$ slpkg -f <packages>'.
The surprise in the end is the reporting of packages sum and size found.
@ -369,6 +369,8 @@ Command Line Tool Usage
lists.
repo-add [repository name] [URL] Add custom repository.
repo-remove [repository] Remove custom repository.
repo-enable Enable or disable default
repositories via dialog utility.
repo-list Print a list of all the
repositories.
repo-info [repository] Get information about a
@ -445,6 +447,18 @@ Command Line Tool Usage
Slpkg Examples
--------------
Enable default repositories edit /etc/slpkg/repositories.conf file or with
command.
(require pythondialog, install with '# slpkg -s sbo python2-pythondialog'):
.. code-block:: bash
$ slpkg repo-enable
.. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/repo_enable.png
:target: https://raw.githubusercontent.com/dslackw/images/master/slpkg/deps2.png
If you use slpkg for the first time will have to create and update the package
list. This command must be executed to update the package lists:

View file

@ -20,6 +20,7 @@ Usage: slpkg Commands:
[upgrade, --only=[...]]
[repo-add [repository name] [URL]]
[repo-remove [repository]]
[repo-enable]
[repo-list]
[repo-info [repository]]
[update [slpkg]]
@ -95,6 +96,11 @@ contain at least the files "PACKAGES.TXT" and "CHECKSUMS.md5" and optional file
.PP
Remove custom repository by name.
.SS repo-enable, enable or disable repositories
\fBslpkg\fP \fBrepo-enable\fP
.PP
Enable or disable repositories via dialog utility (require pythondialog)
.SS repo-list, repositories list
\fBslpkg\fP \fBrepo-list\fP
.PP

View file

@ -50,6 +50,8 @@ Commands:
lists.
repo-add [repository name] [URL] Add custom repository.
repo-remove [repository] Remove custom repository.
repo-enable Enable or disable default
repositories via dialog utility.
repo-list Print a list of all the
repositories.
repo-info [repository] Get information about a
@ -137,6 +139,7 @@ def usage(repo):
[upgrade, --only=[...]]
[repo-add [repository name] [URL]]
[repo-remove [repository]]
[repo-enable]
[repo-list]
[repo-info [repository]]
[update [slpkg]]

View file

@ -41,6 +41,7 @@ from slpkg.version import prog_version
from slpkg.health import PackageHealth
from slpkg.new_config import NewConfig
from slpkg.tracking import TrackingDeps
from slpkg.repoenable import RepoEnable
from slpkg.pkg_find import find_from_repos
from slpkg.arguments import options, usage
from slpkg.slpkg_update import it_self_update
@ -76,6 +77,7 @@ class ArgParse(object):
"upgrade",
"repo-add",
"repo-remove",
"repo-enable",
"repo-list",
"repo-info",
"update-slpkg",
@ -86,8 +88,8 @@ class ArgParse(object):
# checking if repositories exists
if len(self.args) > 1 and self.args[0] not in [
"-h", "--help", "-v", "--version", "upgrade", "repo-list",
"repo-add", "repo-remove", "update", "update-slpkg",
"-h", "--help", "-v", "--version", "upgrade", "repo-enable",
"repo-list", "repo-add", "repo-remove", "update", "update-slpkg",
"health", "-g", "--config"
]:
check_exists_repositories()
@ -127,6 +129,14 @@ class ArgParse(object):
else:
usage("")
def command_repo_enable(self):
"""Repositories enable/disable
"""
if len(self.args) == 1 and self.args[0] == "repo-enable":
RepoEnable().choose()
else:
usage("")
def command_repo_list(self):
"""Repositories list
"""
@ -581,6 +591,7 @@ def main():
"update": argparse.command_update,
"upgrade": argparse.command_upgrade,
"update-slpkg": argparse.command_update_slpkg,
"repo-enable": argparse.command_repo_enable,
"repo-list": argparse.command_repo_list,
"repo-add": argparse.command_repo_add,
"repo-remove": argparse.command_repo_remove,

View file

@ -22,16 +22,21 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from slpkg.utils import Utils
from slpkg.dialog_box import DialogUtil
from slpkg.__metadata__ import MetaData as _meta_
class RepoEnable(object):
"""Read repositories.conf file and update with new enabled or
disabled repositories
"""
def __init__(self):
self.meta = _meta_
self.tag = "[REPOSITORIES]"
self.tag_line = False
self.repositories_conf = "repositories.conf"
self.conf = Utils().read_file(
self.meta.conf_path + self.repositories_conf)
@ -50,40 +55,70 @@ Keys: SPACE select or deselect the highlighted repositories,
TAB move focus
ENTER press the focused button
Disabled <----------------------> Enabled"""
Disabled <-------- REPOSITORIES -------> Enabled"""
self.read_enabled()
self.read_disabled()
self.selected = DialogUtil(self.disabled, text=keys,
title="Enable | Disable Repositories",
backtitle="",
status=False).buildlist(self.enabled)
self.update()
self.update_repos()
self.clear_screen()
self.reference()
def read_enabled(self):
"""Read enable repositories
"""
read_line = False
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
read_line = True
if (line and read_line and not line.startswith("#") and
self.tag_line = True
if (line and self.tag_line and not line.startswith("#") and
self.tag not in line):
self.enabled.append(line)
self.tag_line = False
def read_disabled(self):
"""Read disable repositories
"""
read_line = False
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
read_line = True
if read_line and line.startswith("#"):
self.tag_line = True
if self.tag_line and line.startswith("#"):
line = "".join(line.split("#")).strip()
self.disabled.append(line)
self.tag_line = False
def update(self):
print self.selected
def update_repos(self):
"""Update repositories.conf file with enabled or disabled
repositories
"""
with open("{0}{1}".format(self.meta.conf_path,
self.repositories_conf), "w") as new_conf:
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
self.tag_line = True
if self.tag_line and line.startswith("#"):
repo = "".join(line.split("#")).strip()
if repo in self.selected:
new_conf.write(line.replace(line, repo + "\n"))
continue
if (self.tag_line and not line.startswith("#") and
line != self.tag):
repo = line.strip()
if repo not in self.selected:
new_conf.write(line.replace(line, "# " + line + "\n"))
continue
new_conf.write(line + "\n")
RepoEnable().choose()
def clear_screen(self):
"""Clear screen
"""
os.system("clear")
def reference(self):
"""Reference enable repositories
"""
print("Enabled repositories: {0}".format(", ".join(self.selected)))