update with utils

This commit is contained in:
Dimitris Zlatanidis 2015-01-24 11:01:28 +02:00
parent 593d4fa4c4
commit a7f6a96856
5 changed files with 16 additions and 20 deletions

View file

@ -77,7 +77,7 @@ class BinaryInstall(object):
msg_reading()
self.PACKAGES_TXT, self.mirror = RepoInit(self.repo).fetch()
num_lines = sum(1 for line in self.PACKAGES_TXT)
self.step = (num_lines / 700)
self.step = (num_lines / (100 * len(self.packages)))
def start(self, if_upgrade):
'''

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/>.
from utils import read_file
from __metadata__ import color
@ -32,9 +33,7 @@ class BlackList(object):
def __init__(self):
self.quit = False
self.blackfile = "/etc/slpkg/blacklist"
f = open(self.blackfile, "r")
self.black_conf = f.read()
f.close()
self.black_conf = read_file(self.blackfile)
def packages(self):
'''

View file

@ -24,6 +24,7 @@
import os
from collections import OrderedDict
from utils import read_file
from downloader import Download
from __metadata__ import (
lib_path,
@ -63,10 +64,7 @@ class QueuePkgs(object):
for line in queue_file:
queue.write(line)
queue.close()
f = open(self.queue_list, "r")
self.queued = f.read()
f.close()
self.queued = read_file(self.queue_list)
def packages(self):
'''

View file

@ -25,6 +25,7 @@
import os
import sys
from utils import read_file
from __metadata__ import (
default_repositories,
repositories
@ -35,9 +36,7 @@ class Repo(object):
def __init__(self):
self.repo_file = "/etc/slpkg/custom-repositories"
f = open(self.repo_file, "r")
self.repositories_list = f.read()
f.close()
self.repositories_list = read_file(self.repo_file)
def add(self, repo, url):
'''

View file

@ -26,6 +26,9 @@ import sys
from slpkg.repositories import Repo
from slpkg.blacklist import BlackList
from slpkg.__metadata__ import lib_path
from utils import (
read_file
)
from slpkg.slack.slack_version import slack_ver
@ -38,15 +41,12 @@ def sbo_search_pkg(name):
repo = Repo().sbo()
blacklist = BlackList().packages()
sbo_url = "{0}{1}/".format(repo, slack_ver())
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT",
"r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith("SLACKBUILD LOCATION"):
sbo_name = (line[23:].split("/")[-1].replace("\n", "")
).strip()
if name == sbo_name and name not in blacklist:
SLACKBUILDS_TXT.close()
return (sbo_url + line[23:].strip() + "/")
SLACKBUILDS_TXT = read_file(lib_path + "sbo_repo/SLACKBUILDS.TXT")
for line in SLACKBUILDS_TXT.splitlines():
if line.startswith("SLACKBUILD LOCATION"):
sbo_name = (line[23:].split("/")[-1].replace("\n", "")).strip()
if name == sbo_name and name not in blacklist:
return (sbo_url + line[23:].strip() + "/")
except KeyboardInterrupt:
print("") # new line at exit
sys.exit(0)