def startService(argv): """Main entry point of our rest service.""" # Default Values debug = False port = 8080 listen = "0.0.0.0" try: opts, args = getopt.getopt(argv, "hi:o:", ["debug=", "port=", "listen="]) for opt, arg in opts: if (opt == '-h' or opt == '--help'): print('-d <debugmode> -p <port>') sys.exit() elif opt in ("-d", "--debug"): debug = True elif opt in ("-p", "--port"): port = arg elif opt in ("-l", "--listen"): listen = arg except getopt.GetoptError: print('main.py -debug true|false -port 5000') # sys.exit(2) run(Listen=listen, Port=port, Debug=debug)
def task_do(): while len(TASKS) > 0: try: TASK_ID = TASKS[0] logger.info("Task instance [%s] is running begin..." % TASK_ID) run() except Exception as e: logger.exception(e) finally: logger.info("Task instance [%s] is running end!\r\n" % TASK_ID) TASKS.remove(TASK_ID) TASK_ID = ''
def main(): args = parse_args() known_exceptions = ( SyntaxError, LookupError, UnicodeDecodeError ) blueprint_path = args.blueprint.name csv_path = args.csv.name try: bp = blueprint.parse(blueprint_path) CsvFile(csv_path, bp).close() # just validating service.run(csv_path, bp, args.port, debug=True) return 0 except known_exceptions as e: print(e, file=sys.stderr) return 1
def stop(self): print 'Stopping mysqld:', r = run('mysqld_safe stop') if r.stderr and self._running(): print r.stderr else: print 'mysqld.'
def start(self): print 'Starting mysqld:', r = run('mysqld_safe start') if r.stderr: print r.stderr else: print 'mysqld.'
def setup(): """A setup method.""" # Copies core files to /usr/local/etc/service. service_dir = '/usr/local/etc/service' if not confirm_override_if_exists(service_dir): abort('Installation cancelled.') run('rm -rf %s' % service_dir) run('cp -R %s %s' % (os.getcwd(), service_dir), log=True) # Creates symbolic link to /usr/local/bin/service. ln_target = '/usr/local/bin/service' if not confirm_override_if_exists(ln_target): abort('Installation cancelled.') service_path = os.path.join(service_dir, 'bin', 'service') run('ln -s %s %s' % (service_path, ln_target), log=True) print 'Installed.'
self.send_email( row.email, f'Your reservation at {row.name}', f'This is a reminder of your for ' f'location {row.address}, {row.time},' f'a table for {row.guests}') if __name__ == '__main__': # initiating the service service = NotificationService(use_mock_database=False) # dropping tables for reinitialisation # service.drop_table('reservations') # service.drop_table('tables') # service.drop_table('restaurants') # clearing all tables (firstly the reservation table not to violate # constrains) and filling the restaurants table with initial data. # Since notification service is not the owner of any tables, it # normally would not have permission to edit them, hence the `force` flag # service.clear_table('reservations', force=True) # service.clear_table('tables', force=True) # service.clear_table('restaurants', force=True) # running the service. If reservation service is run afterwards, all the # reservation data added via reservation service will be automatically added # to reservations table of this service print('dziala') service.run()
from resources.lib import context <%_ } else if (props.type == 'Plugin') { -%> from resources.lib import plugin <%_ } else if (props.type == 'Script') { -%> from resources.lib import script <%_ } else if (props.type == 'Service') { -%> from resources.lib import service <%_ } else if (props.type == 'Subtitle') { -%> from resources.lib import subtitle <% } %> import logging import xbmcaddon # Keep this file to a minimum, as Kodi # doesn't keep a compiled copy of this ADDON = xbmcaddon.Addon() kodilogging.config() <%_ if (props.type == 'Contextmenu') { -%> context.run() <%_ } else if (props.type == 'Plugin') { -%> plugin.run() <%_ } else if (props.type == 'Script') { -%> script.show_dialog() <%_ } else if (props.type == 'Service') { -%> service.run() <%_ } else if (props.type == 'Subtitle') { -%> subtitle.run() <% } %>
def _running(self): if int(run('ps aux | grep mysqld | wc -l').stdout) > 1: return True return False
def _available(self): r = run('which mysqld') return not not r.stdout
# Author: Harold.Duan # This module is sbo windows service startup. __version__ = "0.0.1.dev" __author__ = "Harold.Duan" # __all__ = [] from service import run if __name__ == "__main__": try: run() except Exception as e: print(e)
import util, service service.run()
def exists(path): r = run('test -e %s && echo 1 || echo 0' % path) return r.stdout == '1'
def main(): """ The main method for the program """ service.run()