Auth için configfile desteği
This commit is contained in:
@@ -6,6 +6,7 @@ from optparse import OptionParser
|
||||
|
||||
import pisi
|
||||
from pisi.cli import buildhelper, installhelper, indexhelper
|
||||
from pisi.config import config
|
||||
|
||||
usage = """%prog <command> [options] [arguments]
|
||||
|
||||
@@ -56,7 +57,6 @@ class PisiCLI(object):
|
||||
commands = ["help", "build", "install", "index", "updatedb"]
|
||||
|
||||
def __init__(self):
|
||||
|
||||
# first construct a parser for common options
|
||||
# this is really dummy
|
||||
parser = Parser(usage=usage, version="%prog " + pisi.__version__)
|
||||
@@ -125,15 +125,13 @@ class PisiCLI(object):
|
||||
username = self.options.username
|
||||
password = self.options.password
|
||||
if not username and not password:
|
||||
return # No authentication
|
||||
if config.username and config.password:
|
||||
self.authInfo = (config.username, config.password)
|
||||
return
|
||||
elif username and password:
|
||||
self.authInfo = (username, password)
|
||||
return
|
||||
|
||||
# TODO: yapılandırma dosyasını da kontrol et. Belki orada
|
||||
# tanımlanmıştır?
|
||||
|
||||
|
||||
|
||||
if username and self.options.getpass:
|
||||
from getpass import getpass
|
||||
password = getpass("Password: ")
|
||||
|
||||
@@ -19,6 +19,8 @@ class Config(object):
|
||||
def __init__(self):
|
||||
self.conf = ConfigurationFile("/etc/pisi/pisi.conf")
|
||||
self.destdir = self.conf.general.destinationdirectory
|
||||
self.username = self.conf.svn.username
|
||||
self.password = self.conf.svn.password
|
||||
|
||||
# directory accessor functions
|
||||
# here is how it goes
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
#host = i686-pc-linux-gnu
|
||||
#CFLAGS= -mcpu=i686 -O2 -pipe -fomit-frame-pointer
|
||||
#CXXFLAGS= -mcpu=i686 -O2 -pipe -fomit-frame-pointer
|
||||
#
|
||||
#[svn]
|
||||
#username = caglar
|
||||
#password = isteoylebirsey
|
||||
|
||||
import os
|
||||
from ConfigParser import ConfigParser, NoSectionError
|
||||
@@ -30,6 +34,9 @@ class BuildDefaults:
|
||||
CFLAGS = "-mcpu=i686 -O2 -pipe -fomit-frame-pointer"
|
||||
CXXFLAGS= "-mcpu=i686 -O2 -pipe -fomit-frame-pointer"
|
||||
|
||||
class SvnDefaults:
|
||||
"""Default values for [svn] section """
|
||||
username = password = None
|
||||
|
||||
class ConfigurationSection(object):
|
||||
"""ConfigurationSection class defines a section in the configuration
|
||||
@@ -41,6 +48,8 @@ class ConfigurationSection(object):
|
||||
self.defaults = GeneralDefaults
|
||||
elif section == "build":
|
||||
self.defaults = BuildDefaults
|
||||
elif section == "svn":
|
||||
self.defaults = SvnDefaults
|
||||
else:
|
||||
e = "No section by name '%s'" % section
|
||||
raise ConfigException, e
|
||||
@@ -76,3 +85,9 @@ class ConfigurationFile(object):
|
||||
except NoSectionError:
|
||||
builditems = []
|
||||
self.build = ConfigurationSection("build", builditems)
|
||||
|
||||
try:
|
||||
svnitems = parser.items("svn")
|
||||
except NoSectionError:
|
||||
svnitems = []
|
||||
self.svn = ConfigurationSection("svn", svnitems)
|
||||
|
||||
Reference in New Issue
Block a user