def main(): """Main entry point for script.""" # Declarations of Option Parser : https://docs.python.org/2/library/optparse.html parser = OptionParser(version="1.0") parser.add_option("-l", "--list", help="the plugin list", action="store_true", dest="list", default=False) parser.add_option("-a", "--action", help="the action you want to execute", dest="action", default="status") parser.add_option("--verbose", help="show executed commands", action="store_true", dest="debug", default=False) (options, args) = parser.parse_args() # Show the plugin list if options.list: app.show_plugins() return True # Enable the debugging if options.debug: app.enable_debug() # Calling the main function app.main(options, args)
def main(): """Main entry point for script.""" # Declarations of Option Parser : https://docs.python.org/2/library/optparse.html parser = OptionParser(version="1.0") group = OptionGroup(parser, "Specific Options", "Your application parameters") group.add_option("-v", "--view", help="Show this software version", action="store_true", dest="view", default=False) group.add_option("-n", "--name", dest="name", help="Set a name") parser.add_option_group(group) (options, args) = parser.parse_args() # You're actions if options.view: print "What a great view" return True # You're actions if options.name: app.set_name(options.name) # Calling the main function app.main(args)
from src.app import main if __name__ == "__main__": main()
from src import app app.main()
from flask_lambda import FlaskLambda from src.app import main http_server = main(FlaskLambda)
#!/usr/bin/env python import wx import sys from src import app import inspect if __name__ == "__main__": app.main(sys.argv) #test(sys.argv)
import sys from src.app import main if __name__ == '__main__': sys.exit(main())
import curses import os import src.app as app if __name__ == "__main__": """ Set the curses screen and working path """ working_path = os.path.dirname(os.path.abspath(__file__)) myscreen = curses.initscr() curses.start_color() myscreen.nodelay(1) try: curses.noecho() curses.curs_set(0) exc = app.main(myscreen, working_path) finally: curses.echo() curses.endwin() if exc is not None: print(exc)
def test_app(): with open("replied.txt", "w+"), open("subscribed.txt", "w+"): pass app.main(False, test)
import os import sys from src import app # https://stackoverflow.com/questions/7674790/bundling-data-files-with-pyinstaller-onefile def resource_path(relative_path): """ Get absolute path to resource, works for dev and for PyInstaller """ try: # PyInstaller creates a temp folder and stores path in _MEIPASS base_path = sys._MEIPASS except Exception: base_path = os.path.abspath(".") return os.path.join(base_path, relative_path) if __name__ == "__main__": app.main(icon=resource_path("./icon.ico"))
def test_app(): with open("replied.txt", "w+"), open("subscribed.txt", "w+"): pass app.main(True, test, "memeadviser.log")
from flask import Flask from src.app import main http_server = main(Flask)
from src.app import parse_argument, main if __name__ == '__main__': args = parse_argument() main(args)