summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorrsiddharth <rsiddharth@ninthfloor.org>2013-12-11 18:12:55 +0530
committerrsiddharth <rsiddharth@ninthfloor.org>2013-12-11 18:12:55 +0530
commitb3353011ab44c619c4e944b2c654829924127ff6 (patch)
tree79bc4fbfa090bdcfb796654f4af02ff6473782f9 /src
parente5a9c1cc56de587cd2d5ce140de9f903b143026f (diff)
The functions get_paraphernalia & read_gns_readme use methods from os & os.path to handle files & directories.
Diffstat (limited to 'src')
-rw-r--r--src/gns-deb-diff.py37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/gns-deb-diff.py b/src/gns-deb-diff.py
index 303723f..3a933df 100644
--- a/src/gns-deb-diff.py
+++ b/src/gns-deb-diff.py
@@ -7,6 +7,9 @@
import subprocess as child
import shlex
+import os.path as path
+import os
+from sys import exit
# global variables.
bzr_base_url = ""
@@ -76,18 +79,31 @@ def get_paraphernalia():
bzr_base_url = "bzr://bzr.savannah.gnu.org/gnewsense/packages-parkes"
# directory under which the bzr branches has to be stored.
- local_dir = raw_input(">> local directory to store bzr branch: ").strip()
+ stdin = raw_input(">> local directory to store bzr branches: ").strip()
+
+ if (len(stdin) !=0):
+ local_dir = path.abspath(stdin)
+ else:
+ local_dir = path.expanduser("~/gnewsense/packages-parkes")
+
+ if not path.isdir(local_dir):
+ try:
+ os.makedirs(local_dir)
+ except OSError, e:
+ print "ERROR: Unable to create %s directory" % local_dir
+ exit(1)
- # absolute path to file which contains the packages names.
- # one package per line.
- stdin = raw_input(">> packages list file (absolute path): ").strip()
+
+ # packages list file should contain package names listed one per
+ # line.
+ stdin = raw_input(">> packages list file: ").strip()
if (len(stdin) != 0):
- pkgs_file = stdin
+ pkgs_file = path.abspath(stdin)
else:
- pkgs_file = "packages-parkes.list"
+ pkgs_file = path.abspath("packages-parkes.list")
- packages_list = get_packages()
+ packages_list = get_packages_list()
return packages_list
@@ -101,10 +117,11 @@ def read_gns_readme(package):
global local_dir
+ readme_file_path = path.join(local_dir, package,
+ "debian/README.gNewSense")
+
try:
- readme_file = open("%s/%s/debian/README.gNewSense" % (local_dir,
- package),
- 'r')
+ readme_file = open(readme_file_path, 'r')
except IOError, e:
print e
return None # give up!