summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCtibor <ctibor@brancik.cz>2017-03-17 19:35:31 +0100
committerCtibor <ctibor@brancik.cz>2017-03-17 19:35:31 +0100
commit0996f26be8d1f23676804c14d6ce374432489e24 (patch)
treec90c4640d30036f6934d17f2424d90dcb378b26b /tools
parentfbb769fc3764d3813c617f66677f967a7268fb3e (diff)
downloadrpi-config-0996f26be8d1f23676804c14d6ce374432489e24.tar.gz
rpi-config-0996f26be8d1f23676804c14d6ce374432489e24.tar.bz2
Add action.py and further improve check.py
Diffstat (limited to 'tools')
-rw-r--r--tools/.sync-rpi.conf.kate-swpbin517 -> 0 bytes
-rw-r--r--tools/action.py30
-rw-r--r--tools/check.py (renamed from tools/sync-rpi-config.py)31
-rw-r--r--tools/config.py2
-rw-r--r--tools/config.pycbin210 -> 0 bytes
-rw-r--r--tools/sync-rpi.conf7
6 files changed, 60 insertions, 10 deletions
diff --git a/tools/.sync-rpi.conf.kate-swp b/tools/.sync-rpi.conf.kate-swp
deleted file mode 100644
index 373ddea..0000000
--- a/tools/.sync-rpi.conf.kate-swp
+++ /dev/null
Binary files differ
diff --git a/tools/action.py b/tools/action.py
new file mode 100644
index 0000000..a2d0ba0
--- /dev/null
+++ b/tools/action.py
@@ -0,0 +1,30 @@
+# The basic workflow is like this:
+# git rsync
+# [remote git] <-> [local git] <-> [local storage]
+#
+# If action PULL is specified:
+# 1. git pull from remote repo
+# 2. rsync local repo to local storage
+#
+# If action PUSH is specified:
+# 1. rsync from local storage to local repo
+# 2. git push to remote repo
+
+# Pull config files from git repo
+
+import git
+
+def repo_pull():
+ pass
+
+# Push config files to git repo
+def repo_push():
+ pass
+
+# Pull config files from local storage to be pushed to repo
+def local_pull():
+ pass
+
+# Push config pulled from repo to local storage
+def local_push():
+ pass
diff --git a/tools/sync-rpi-config.py b/tools/check.py
index 9496c70..efa2449 100644
--- a/tools/sync-rpi-config.py
+++ b/tools/check.py
@@ -7,7 +7,7 @@ def get_opts(argv):
try:
opts, args = getopt.getopt(argv,"ha:c:d:l",["conf=","action=","device=","list-devices"])
except getopt.GetoptError:
- print 'sync-rpi-config: -a <push/pull> -c <conf file> -d <device>'
+ usage()
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
@@ -25,8 +25,9 @@ def get_opts(argv):
# Check parameters for errors
def check_opts():
+ get_opts(sys.argv[1:])
if not config.action:
- print "Error: No action has been specified."
+ print "Error: No action has been specified. Use -a."
return usage()
sys.exit(2)
if not config.action == "pull" or config.action == "push":
@@ -34,7 +35,7 @@ def check_opts():
return usage()
sys.exit(2)
if not config.device:
- print "Error: No device has been specified."
+ print "Error: No device has been specified. Use -d."
return usage()
sys.exit(2)
if config.device:
@@ -54,19 +55,33 @@ def load_config(configfile):
# Check if configuration file is sane
def check_config(configfile):
- options_config = ['repo', 'repo_path', 'rpi1', 'rpi2', 'rpi3' ]
- options_device = ['type']
+ get_opts(sys.argv[1:])
load_config(config.configfile)
- for option in options_config:
+ error = 0
+ #print config.configfile
+ #print ini.items('config')
+ #print ini.items('alcor-01')
+ #print config.options_config
+ #print config.options_device
+ for option in config.options_config:
if not ini.has_option('config', option):
- print "Option " + option + " not set in config"
- break
+ print "Error: Option \"" + option + "\" not set in [config]."
+ error = 1
+ for section in ini.sections():
+ for option in config.options_device:
+ if section != 'config' and not ini.has_option(section, option):
+ print "Error: Option " + option + " not set in [" + section + "]."
+ error = 1
+
+ if error == 1:
+ sys.exit(2)
# List all devices defined in config.configfile
def list_devices():
load_config(config.configfile)
return " ".join(ini.sections()[1:])
+# Prin usage
def usage():
print """Usage: sync-rpi-config -a ACTION -d DEVICE [ -c [FILE] ] [ -l ]
Options
diff --git a/tools/config.py b/tools/config.py
index 61dacd8..c8e6ec3 100644
--- a/tools/config.py
+++ b/tools/config.py
@@ -1,3 +1,5 @@
configfile = ''
device = ''
action = ''
+options_config = [ 'repo', 'repo_path', 'rpi1', 'rpi2', 'rpi3', 'rpi1_path', 'rpi2_path', 'rpi3_path' ]
+options_device = [ 'type', ]
diff --git a/tools/config.pyc b/tools/config.pyc
deleted file mode 100644
index 270f526..0000000
--- a/tools/config.pyc
+++ /dev/null
Binary files differ
diff --git a/tools/sync-rpi.conf b/tools/sync-rpi.conf
index b9651c1..b2ac111 100644
--- a/tools/sync-rpi.conf
+++ b/tools/sync-rpi.conf
@@ -1,8 +1,11 @@
[config]
## Define directories, where you store crosscompiled environment
+rpi1=true
+rpi2=true
+#rpi3=true
rpi1_path=/usr/armv6j-hardlofat-linux-gnueabi
rpi2_path=/usr/armv7a-hardfloat-linux-gnueabi
-rpi3_path=/usr/aarch64-uknown-linux-gnu
+#rpi3_path=/usr/aarch64-uknown-linux-gnu
## Full URI to the git repository holding configuration files
repo=ssh://git@git.brancik.cz/rpi-config.git
@@ -14,6 +17,6 @@ repo_path=conf
## Name the section after the device
[alcor-01]
## Define the type of RPi being used
-type = rpi1
+type=rpi1
[alcor-02]
[mizar]