From 2b721124f5122faae5709e5e2dd8035f392c1361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Ismael=20Haase=20Hern=C3=A1ndez?= Date: Sun, 10 Apr 2011 15:18:17 -0500 Subject: config.py import config.sh settings --- config.py | 72 ++++++++++++++++++++++++++++++--------------------------------- config.sh | 6 +++--- 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/config.py b/config.py index bd8ef1b..56a7c81 100644 --- a/config.py +++ b/config.py @@ -1,44 +1,36 @@ -#!/usr/bin/python +#!/usr/bin/pythonn # -*- coding: utf-8 -*- -from user import home -import commands +try: + from subprocess import check_output +except(ImportError): + from commands import getoutput as check_output +import os -time__ = commands.getoutput("date +%Y%m%d-%H:%M") +stringvars=("mirror", "mirrorpath", "logname", "tempdir", "docs_dir", + "repodir",) +listvars=("repo_list", "dir_list", "arch_list", "other",) +boolvars=("output", "debug",) -# Mirror Parameters -mirror = "mirrors.eu.kernel.org" -mirrorpath = "::mirrors/archlinux" +config=dict() -# Directories and files +def exit_if_none: + if os.environ.get(var) is None: + exit("%s is not defined" % var) -## Optionals -path = home + "/parabolagnulinux.org" -docs = path + "/docs" -logdir = path + "/log" - -## Must be defined -logname= logdir + "/" + time__ + "-repo-maintainer.log" -repodir= path + "/repo" -tmp = home + "/tmp" -archdb = tmp + "/db" - -free_path= path + "/free/" - -# Repo, arch, and other folders to use for repo -repo_list = ("core", "extra", "community", "testing", "community-testing", "multilib") -dir_list = ("pool","sources") -arch_list = ("i686", "x86_64") -other = ("any",) - -# Output -output = True -verbose = False - -# Files -blacklist = docs + "/blacklist.txt" -whitelist = docs + "/whitelist.txt" -pending = docs + "/pending" -rsync_blacklist = docs + "/rsyncBlacklist" +for var in stringvars: + exit_if_none(var) + config[var]=os.environ.get(var) +for var in listvars: + exit_if_none(var) + config[var]=tuple(os.environ.get(var).split(":")) +for var in boolvars: + exit_if_none(var) + if os.environ.get(var) == "True": + config[var]=True + elif os.environ.get(var) =="False": + config[var]=False + else: + print('%s is not True or False' % var) # Classes and Exceptions class NonValidFile(ValueError): pass @@ -55,7 +47,8 @@ class Package: "release" : False, "arch" : False, "license" : False, - "location": False} + "location": False, + "depends" : False,} def __setitem__(self, key, item): if key in self.package_info.keys(): @@ -76,8 +69,11 @@ class Package: if not isinstance(x, Package): return False for key in self.package_info.keys(): - if x[key] != self[key]: + if x[key] != self.package_info[key]: return False else: return True +if __name__=="__main__": + for key in config.keys(): + print("%s : %s" % (key,config[key])) diff --git a/config.sh b/config.sh index aae3287..66be477 100755 --- a/config.sh +++ b/config.sh @@ -1,6 +1,7 @@ #!/bin/sh # -*- coding: utf-8 -*- + # Mirror options mirror="mirrors.eu.kernel.org" mirrorpath="::mirrors/archlinux" @@ -18,7 +19,7 @@ docs_dir=${paraboladir}/docs repodir=${paraboladir}/repo # Repos, arches, and dirs for repo -repolist="core:extra:community:testing:community-testing:multilib" +repo_list="core:extra:community:testing:community-testing:multilib" dir_list="pool" arch_list="i686:x86_64" other="any" @@ -28,7 +29,6 @@ output="True" debug="False" # Rsync commands -rsync_list_command="rsync -a --no-motd --list-only " rsync_update_command="rsync -av --delay-updates --exclude=*.{abs|db}.tar.* " rsync_post_command="rsync -av --delete --exclude=*.abs.tar.* " @@ -41,7 +41,7 @@ function run_python_cmd { tempdir=${tempdir} \ docs_dir=${docs_dir} \ repodir=${repodir} \ - repolist=${repolist} \ + repo_list=${repo_list} \ dir_list=${dir_list} \ arch_list=${arch_list} \ other=${other} \ -- cgit v1.1-4-g5e80