Files
entropy/handlers/activator
T
lxnay 8175b17efe some heavy work on activator
git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@201 cd1c1023-2f26-0410-ae45-c471fc1f0318
2007-03-27 23:02:26 +00:00

101 lines
4.4 KiB
Python

#!/usr/bin/python
'''
# DESCRIPTION:
# Entropy mirrors syncing manager
Copyright (C) 2007 Fabio Erculiani
This program 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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
# Never do "import portage" here, please use entropyTools binding
import os
import sys
import string
sys.path.append('../libraries')
import entropyTools
import activatorTools
from entropyConstants import *
# CONSTANTS
APPNAME = "activator"
APPVERSION = "1.0"
def print_help():
entropyTools.print_info("Sabayon Linux "+APPNAME+" (C - 2007)")
entropyTools.print_info("General Options:")
entropyTools.print_info(" --help\t\tthis output")
entropyTools.print_info(" --version\t\tprint version")
entropyTools.print_info(" --verbose\t\tprint debugging info")
entropyTools.print_info(" --nocolor\t\tdisable colorized output")
entropyTools.print_info(entropyTools.blue("Tools available: "))
entropyTools.print_info(" \t"+entropyTools.green(entropyTools.bold("sync"))+entropyTools.yellow("\t\t to sync all the upload mirrors"))
entropyTools.print_info(" \t\t"+entropyTools.red("--download-packages")+"\t to download all the binary packages (will overwrite)")
entropyTools.print_info(" \t\t"+entropyTools.red("--download-etp")+"\t\t to download all the Entropy tree (will overwrite)")
entropyTools.print_info(" \t\t"+entropyTools.red("--show-stats")+"\t\t shows the list of validated package/etp-file couples")
entropyTools.print_info(" \t"+entropyTools.green(entropyTools.bold("packages"))+entropyTools.yellow("\t to manage binary packages"))
entropyTools.print_info(" \t\t"+entropyTools.red("--ask")+"\t\t\t ask before making any changes")
entropyTools.print_info(" \t\t"+entropyTools.red("--pretend")+"\t\t just show what would be done")
entropyTools.print_info(" \t\t"+entropyTools.green("sync")+entropyTools.red("\t\t\t to sync the binary packages across primary mirrors"))
entropyTools.print_info(" \t"+entropyTools.green(entropyTools.bold("database"))+entropyTools.yellow("\t to manage database status and settings"))
entropyTools.print_info(" \t\t"+entropyTools.green("lock")+entropyTools.red("\t\t\t to lock the database(s) status ["+entropyTools.yellow("DANGEROUS")+entropyTools.red("]")))
entropyTools.print_info(" \t\t"+entropyTools.green("unlock")+entropyTools.red("\t\t\t to unlock the database(s) status ["+entropyTools.yellow("DANGEROUS")+entropyTools.red("]")))
entropyTools.print_info(" \t\t"+entropyTools.green("download-lock")+entropyTools.red("\t\t to lock the download mirror status"))
entropyTools.print_info(" \t\t"+entropyTools.green("download-unlock")+entropyTools.red("\t\t to unlock the download mirror status"))
entropyTools.print_info(" \t\t"+entropyTools.green("lock-status")+entropyTools.red("\t\t to show the current locks status of the mirrors"))
options = sys.argv[1:]
# no color parsing
_options = []
for opt in options:
if (opt == "--nocolor"):
entropyTools.nocolor()
else:
_options.append(opt)
options = _options
# print version
if (string.join(options).find("--version") != -1) or (string.join(options).find(" -V") != -1):
entropyTools.print_generic(APPNAME+": "+APPVERSION)
sys.exit(0)
# print help
if len(options) < 1 or string.join(options).find("--help") != -1 or string.join(options).find(" -h") != -1:
print_help()
if len(options) < 1:
entropyTools.print_error("not enough parameters")
sys.exit(1)
if (not entropyTools.isRoot()):
entropyTools.print_error("you must be root in order to run "+APPNAME)
sys.exit(2)
# sync mirrors tool
# will be removed
if (options[0] == "sync"):
activatorTools.sync(options[1:])
sys.exit(0)
# database tool
if (options[0] == "database"):
activatorTools.database(options[1:])
sys.exit(0)
# database tool
if (options[0] == "packages"):
activatorTools.packages(options[1:])
sys.exit(0)