From e44a14899cbf37efe27124d86328b4833bf9d875 Mon Sep 17 00:00:00 2001 From: Thomas Meissner Date: Fri, 11 Mar 2016 22:16:08 +0100 Subject: [PATCH] =?UTF-8?q?M=C3=B6glichkeit=20das=20daemon-File=20neu=20er?= =?UTF-8?q?zeugen=20zu=20lassen.=20Das=20Template=20wird=20dabei=20von=20G?= =?UTF-8?q?itHub=20geladen,=20geparst=20und=20unter=20/etc/init.d/doorpi?= =?UTF-8?q?=20abgelegt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Start mit ``` sudo ./recreate_daemon_file.py ``` --- doorpi/docs/service/recreate_daemon_file.py | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 doorpi/docs/service/recreate_daemon_file.py diff --git a/doorpi/docs/service/recreate_daemon_file.py b/doorpi/docs/service/recreate_daemon_file.py new file mode 100755 index 00000000..ca9e7b71 --- /dev/null +++ b/doorpi/docs/service/recreate_daemon_file.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import doorpi.metadata as metadata +import os +import urllib2 + +print("start to create daemon file now...") + + +def parse_string(raw_string): + for meta_key in dir(metadata): + if not meta_key.startswith('__'): + raw_string = raw_string.replace('!!%s!!' % meta_key, str(getattr(metadata, meta_key))) + return raw_string + + +def main(): + url = 'https://raw.githubusercontent.com/motom001/DoorPi/master/'+metadata.daemon_name_template + daemon_filename = os.path.join(metadata.daemon_folder, metadata.daemon_name) + print("start down download and parse new daemon file:") + print("URL: "+url) + print("FILE: "+daemon_filename) + with open(daemon_filename, "w") as daemon_file: + for line in urllib2.urlopen(url): + daemon_file.write(parse_string(line)) + print("download successfully - change chmod to 0755 now") + os.chmod(daemon_filename, 0755) + print "finished" + +if __name__ == '__main__': + main()