summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAuke Booij (tulcod) <auke@tulcod.com>2010-07-28 10:07:43 +0200
committerAuke Booij (tulcod) <auke@tulcod.com>2010-07-28 10:07:43 +0200
commite1dcb2cadd83bbac0138f2439d2351b2fd614cdb (patch)
tree0515c349385ca75e6eba1c7997058b28778a369d
parentStart development of g-common (diff)
downloadg-cran-e1dcb2cadd83bbac0138f2439d2351b2fd614cdb.tar.gz
g-cran-e1dcb2cadd83bbac0138f2439d2351b2fd614cdb.tar.bz2
g-cran-e1dcb2cadd83bbac0138f2439d2351b2fd614cdb.zip
Starting gcommon dev branch... nothing useful here
-rw-r--r--g_common/g_common.py73
-rw-r--r--g_common/settings.py2
2 files changed, 34 insertions, 41 deletions
diff --git a/g_common/g_common.py b/g_common/g_common.py
index c5c1120..f7c483b 100644
--- a/g_common/g_common.py
+++ b/g_common/g_common.py
@@ -1,66 +1,56 @@
#!/usr/bin/python
-import getopt, sys, os, string, urllib, re
+import getopt, sys, os, string, urllib, re, configparser
import settings
#__doc__="Usage: "+sys.argv[0]+" <local repository directory> <action> [<action arguments>...]"
def list_configured_drivers():
- return [os.listdir(settings.GLOBAL_CONF_DIR)]
+ #all .cfg files which end in .cfg as they should
+ return [x[:-len('.cfg')] for x in os.listdir(settings.GLOBAL_CONF_DIR) if x[-len('.cfg'):]=='.cfg']
+#read key=value file to dict
+def read_config(conf_file,defaults={}):
+ return configparser.ConfigParser(conf_file,defaults).items('DEFAULTS')
+
+#returns dict of key=value config file
def read_driver_config(driver_name):
-
+ conffile=os.path.join('/etc/g-common',driver_name+'.cfg')
+ return read_config(conffile,{
+ #'name':None,
+ #'executable':None,
+ })
+ return configs #dict
+
+#read g-common config for a repo
+def read_repo_config(repo_location):
+ hidden_conffile=os.path.join(repo_location,settings.MYDIR,'conf')
+ return read_config(hidden_conffile)
#sync a local repository's PACKAGES file
def action_sync(repo_location,remote_uri):
- if not os.path.isdir(os.path.join(repo_location, REPO_MYDIR)):
- os.mkdir(os.path.join(repo_location,REPO_MYDIR))
- packages_filename=os.path.join(repo_location, REPO_MYDIR, 'PACKAGES')
- urllib.urlretrieve(remote_uri+'/src/contrib/PACKAGES',packages_filename)
- repo_file=open(os.path.join(repo_location,REPO_MYDIR,'remote_uri'),'w')
- repo_file.write(remote_uri)
+ #todo
+ raise NotImplementedError
#list categories in this repositorie
def list_categories(repo_location):
- print "dev-R"
+ #todo
+ raise NotImplementedError
#idem ditto
def list_packages(repo_location):
- packages=read_packages(os.path.join(repo_location,REPO_MYDIR,'PACKAGES'),repo_location)
- for package in packages:
- print 'dev-R/'+package.ebuild_vars['pn'],package.ebuild_vars['pv']
+ #todo
+ raise NotImplementedError
#generate a tree of ebuilds... note that we only link ebuild files
#metadata.xml and Manifest and whatnot is not generated
def generate_tree(repo_location):
- packages=read_packages(os.path.join(repo_location,REPO_MYDIR,'PACKAGES'),repo_location)
- ebuild_file=os.path.join(os.path.dirname(__file__),'cran.ebuild')
- for package in packages:
- ebuild_dir=os.path.join(repo_location,'dev-R',package.ebuild_vars['pn'])
- if not os.path.exists(ebuild_dir):
- os.makedirs(ebuild_dir)
- os.symlink(ebuild_file,os.path.join(ebuild_dir,package.ebuild_vars['pn']+'-'+package.ebuild_vars['pv']+'.ebuild'))
+ #todo
+ raise NotImplementedError
#list package details, in PMS's format
def action_package(repo_location,package_name):
- defined_phases=[]
- package=find_package(repo_location,package_name[package_name.find('/')+1:])
- #output data
- for key,value in package.ebuild_vars.iteritems():
- if key=='pn' or key=='pv': #readonly vars, we cannot set these in ebuilds
- pass
- elif isinstance(value,str): #if string
- print key.upper()+'='+value.replace('\n','')
- elif isinstance(value,list) and key=='license':
- if len(value)>1:
- print "LICENSE=|| ( "+' '.join(value)+' )'
- else:
- print "LICENSE="+' '.join(value)
- elif isinstance(value,list): #list, concat items
- print key.upper()+'='+' '.join(value).replace('\n','')
- for pms_func in pms_phases:
- if hasattr(phases,pms_func):
- defined_phases.append(pms_func)
- print 'GCOMMON_PHASES='+' '.join(defined_phases)
+ #todo
+ raise NotImplementedError
def usage():
print __doc__
@@ -96,8 +86,9 @@ def main():
action_package(repo_location,package_name)
elif action=='usage':
usage()
- elif action in pms_phases and hasattr(phases,action):
- getattr(phases,action)(os.environ,repo_location)
+ elif action in pms_phases:
+ #todo
+ raise NotImplementedError
elif action in actions_wanted:
raise NotImplementedError
else:
diff --git a/g_common/settings.py b/g_common/settings.py
index 3fb5118..4ce4f6a 100644
--- a/g_common/settings.py
+++ b/g_common/settings.py
@@ -1 +1,3 @@
GLOBAL_CONF_DIR='/etc/g-common/'
+MYDIR='.g-common'
+