Esempio n. 1
0
def main():
    try:
        app = ElastiCluster()
        app.run()
    except KeyboardInterrupt:
        sys.stderr.write("""
WARNING: execution interrupted by the user!
Your clusters may be in inconsistent state!
""")
        return 1
    def main(self):
        """
        Run the application.
        """
        command = self.params.command.lower()
        matched = self.match(command)

        # If an application is matched, run it; else, throw an error.
        if matched:
            app = matched(argv=self.proxied_argv)
            app.run()
        else:
            raise cli.app.Abort("Aborted: command not found: " + self.params.command)
Esempio n. 3
0
from slackclient import SlackClient
import cli.app
import psutil
import os
from flask import Flask, request


@cli.app.CommandLineApp
def app(app):
    slack_token = 'xoxp-357964064544-358115947873-359555646406-da306896a6f1df139e6f97ecd35134e7'
    sc = SlackClient(slack_token)
    sc.api_call("chat.postMessage",
                channel="test-exam",
                text=str(psutil.cpu_times()) + "\n\n" +
                str(psutil.cpu_percent(interval=1, percpu=True)) + "\n\n" +
                str(psutil.cpu_stats()) + "\n\n" +
                str(psutil.virtual_memory()) + "\n\n" +
                str(psutil.swap_memory()) + "\n\n" +
                str(psutil.disk_partitions()) + str(psutil.disk_usage('/')))


if __name__ == "__main__":
    app.run()
Esempio n. 4
0
# coding: utf-8
from cli import app

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=False, threaded=True)
Esempio n. 5
0
            print(msg)

    @staticmethod
    def print_error(msg):
        """Print an error message

        :param msg: string to print
        """
        print(msg, file=sys.stderr)

    def print(self, msg):
        """Print a regular message

        :param msg: string to print
        """
        if not self.params.quiet:
            print(msg)

if __name__ == "__main__":
    app = TBBInstallApp()
    try:
        app.run()
    except SystemExit as ex:
        sys.exit(ex.code)
    except KeyboardInterrupt as ex:
        sys.exit(1)
    except:
        type, value, tb = sys.exc_info()
        traceback.print_exc()
        pdb.post_mortem(tb)