From c8cbed4aaa58ef99ac240deb7a66a49369d0420e Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Sun, 2 Oct 2011 15:48:28 +0200 Subject: [PATCH] Added help text --- bundle.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/bundle.py b/bundle.py index 8a6bd46..70cc094 100755 --- a/bundle.py +++ b/bundle.py @@ -41,7 +41,7 @@ class Bundle(): # Create packing information package_info = { - 'name': self._appname, + 'appname': self._appname, 'appcmd': self._appcmd, 'appdir': os.path.basename (self._appdir), } @@ -87,6 +87,11 @@ class Bundle(): handle.write (file_content.decode ("utf-8")) return self._bundle_path + def tar_filter (self, tarinfo): + """Check if a file has to be packed or not, + and skips files such as version control logs + and source files""" + pass def unbundle_app (self): """Unbundle app assuming that it is contained in this file""" @@ -108,6 +113,7 @@ class Bundle(): tar.close () package_info = json.load (open ("info.bundle", "r")) + print_msg ("Launching %s" % package_info["appname"]) os.chdir (package_info["appdir"]) # Executing the program @@ -120,8 +126,36 @@ class Bundle(): def print_msg (msg): print ("\033[31;1m> \033[0m%s" % msg) +def print_help (): + help_text = """ +Bundle.py v0.1 --- A simple framework to pack applications + +bundle.py is a simple python script that packs compiled application +in a single autoextracting python file that can be executed and +runs the application. + +To pack your application, simply create an application.info file +similar to this (JSON coded dictionary) + +{ + "appname": "My beatiful application", + "appdir": "/home/me/dev/my_app", + "appcmd": "./src/my_app" +} + +and then run ./bundle.py application.info +""" + print (help_text) + sys.exit (0) + if __name__ == "__main__": + # Check if this is the bundle.py source file + # and if it does not contain a bundle + with open (__file__, "r") as handle: + if len(sys.argv) <= 1 and not (15 * "#") in handle.read (): + print_help () + print_msg ("Starting bundle framework") if len (sys.argv) <= 1: -- 2.1.4