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