diff options
author | Auke Booij (tulcod) <auke@tulcod.com> | 2010-07-31 13:33:20 +0200 |
---|---|---|
committer | Auke Booij (tulcod) <auke@tulcod.com> | 2010-07-31 15:10:21 +0200 |
commit | e13d6b7d5b37de4612e5ebcba1d09683842a8eb5 (patch) | |
tree | 2d9dbbf2716ead4d3911e29578afe927b34fec57 | |
parent | Move g-cran config file (diff) | |
download | g-cran-e13d6b7d5b37de4612e5ebcba1d09683842a8eb5.tar.gz g-cran-e13d6b7d5b37de4612e5ebcba1d09683842a8eb5.tar.bz2 g-cran-e13d6b7d5b37de4612e5ebcba1d09683842a8eb5.zip |
Make MYDIR
-rw-r--r-- | g_common/g_common.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/g_common/g_common.py b/g_common/g_common.py index c671b5c..17742bc 100644 --- a/g_common/g_common.py +++ b/g_common/g_common.py @@ -18,7 +18,11 @@ def read_config(conf_file,defaults={}): conf=defaults.copy() for line in conffile: if len(line): - conf[line[:line.find("=")]]=line[line.find("=")+1:] + value=line[line.find("=")+1:] + if value[-1]=='\n': + value=value[:-1] + conf[line[:line.find("=")]]=value + return conf #returns dict of key=value config file @@ -44,11 +48,15 @@ def action_sync(repo_location,driver,remote_uri): if remote_uri is None: remote_uri=repo_conf['uri'] - #todo write repo.cfg + if os.path.exists(repo_location): + try: + os.makedirs(os.path.join(repo_location,settings.MYDIR)) + except: + pass cfg_file=open(os.path.join(repo_location,settings.MYDIR,"repo.cfg"),"w") - cfg_file.write('driver='+driver) - cfg_file.write('uri='+remote_uri) + cfg_file.write('driver='+driver+'\n') + cfg_file.write('uri='+remote_uri+'\n') cfg_file.close() return verbose_system(driver_conf['exec']+" "+repo_location+" sync "+remote_uri) @@ -82,8 +90,8 @@ def generate_tree(repo_location): ebuild_file=settings.COMMON_EBUILD_FILE #get from settings - packages_list_pipe=subprocess.Popen(fixme,shell=True,stdout=subprocess.PIPE) - os.waitpid(process.pid,0) + packages_list_pipe=subprocess.Popen(driver_conf['exec']+' '+repo_location+' list-packages',shell=True,stdout=subprocess.PIPE) + os.waitpid(packages_list_pipe.pid,0) for line in packages_list_pipe.stdout: category=line[:line.find("/")] package=line[line.find("/")+1:line.find(" ")] @@ -91,7 +99,7 @@ def generate_tree(repo_location): ebuild_dir=os.path.join(repo_location,category,package) 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')) + os.symlink(ebuild_file,os.path.join(ebuild_dir,package+'-'+version+'.ebuild')) #list package details, in PMS's format def action_package(repo_location,package_name): @@ -125,7 +133,7 @@ def main(): if len(arguments)>2: driver=arguments[2] if len(arguments)>3: - remote_repo=arguments[2] + remote_repo=arguments[3] action_sync(repo_location,driver,remote_repo) elif action=='list-categories': list_categories(repo_location) |