Пример #1
0
def build_app(spec, log_dir, preload=False):
    name = spec["name"]
    app = App.get_app(name)
    if app and app.build_state == App.BuildState.BUILDING:
        print("App {} already building. Wait for build to complete before resubmitting.".format(name))
        return
    new_app = App.create(spec)
    try:
        new_app.build(preload=preload)
    except Exception as e:
        # the "catch-all" clause
        print("Could not build app {}: {}".format(new_app.name, e))
        App.index.update_build_state(App.BuildState.FAILED)
Пример #2
0
def build_app(spec, log_dir, preload=False):
    name = spec["name"]
    app = App.get_app(name)
    if app and app.build_state == App.BuildState.BUILDING:
        print("App {} already building. Wait for build to complete before resubmitting.".format(name))
        return
    new_app = App.create(spec)
    try:
        new_app.build(preload=preload)
    except Exception as e:
        # the "catch-all" clause
        print("Could not build app {}: {}".format(new_app.name, e))
        App.index.update_build_state(App.BuildState.FAILED)
Пример #3
0
 def _configure_app_loggers(self):
     make_dir(LogSettings.APPS_DIRECTORY)
     apps = App.get_app()
     for app in apps:
         if not app in self._app_loggers:
             logger = self._make_app_logger(app.name)
             self._app_loggers[app.name] = logger 
Пример #4
0
def build_app(spec, log_dir, preload=False):
    name = spec["name"]
    sys.stdout = open(os.path.join(log_dir, name + "-" + str(os.getpid()) + ".out"), "w", buffering=0)
    sys.stderr = open(os.path.join(log_dir, name + "-" + str(os.getpid()) + ".err"), "w", buffering=0)
    app = App.get_app(name)
    print("In build_app")
    if app and app.build_state == App.BuildState.BUILDING:
        print("App {} already building. Wait for build to complete before resubmitting.".format(name))
        return
    new_app = App.create(spec)
    try:
        new_app.build(preload=preload)
    except Exception as e:
        # the "catch-all" clause
        print("Could not build app {}: {}".format(new_app.name, e))
        App.index.update_build_state(App.BuildState.FAILED)
Пример #5
0
 def get(self, organization, repo):
     super(StaticLogsHandler, self).get()
     app_name = App.make_app_name(organization, repo)
     app = yield self._get_app(app_name)
     time_string = datetime.datetime.strftime(app.last_build_time, LogSettings.TIME_FORMAT)
     logs = yield self._get_app_logs(app_name, time_string)
     self.write({"logs": logs})
Пример #6
0
 def get(self, organization, repo):
     super(StaticLogsHandler, self).get()
     app_name = App.make_app_name(organization, repo)
     app = yield self._get_app(app_name)
     time_string = datetime.datetime.strftime(app.last_build_time,
                                              LogSettings.TIME_FORMAT)
     logs = yield self._get_app_logs(app_name, time_string)
     self.write({"logs": logs})
Пример #7
0
 def get(self, organization, repo):
     super(StaticLogsHandler, self).get()
     app_name = App.make_app_name(organization, repo)
     app = yield self._get_app(app_name)
     time_string = datetime.datetime.strftime(app.last_build_time, LogSettings.TIME_FORMAT)
     filtered = self.get_query_argument('filtered', default='false').lower() == 'true'
     logs = yield self._get_app_logs(app_name, time_string, filtered)
     self.write({"logs": logs})
Пример #8
0
 def get(self, organization, repo):
     super(GithubStatusHandler, self).get()
     app_name = App.make_app_name(organization, repo)
     app = yield self._get_app(app_name)
     if not app:
         self.set_status(404)
         self.write({"error": "app does not exist"})
     else:
         self._write_build_state(app)
Пример #9
0
 def get(self, organization, repo):
     super(GithubStatusHandler, self).get()
     app_name = App.make_app_name(organization, repo)
     app = yield self._get_app(app_name)
     if not app:
         self.set_status(404)
         self.write({"error": "app does not exist"})
     else:
         self._write_build_state(app)
Пример #10
0
    def open(self, organization, repo):
        super(LiveLogsHandler, self).open()
        print("Opening websocket for {}/{}".format(organization, repo))
        app_name = App.make_app_name(organization, repo)

        ws_handlers.append(self)

        self._thread = LiveLogsHandler.LogsThread(app_name, self)
        self._thread.start()
Пример #11
0
    def open(self, organization, repo):
        super(LiveLogsHandler, self).open()
        print("Opening websocket for {}/{}".format(organization, repo))
        app_name = App.make_app_name(organization, repo)

        ws_handlers.append(self)

        self._thread = LiveLogsHandler.LogsThread(app_name, self)
        self._thread.start()
Пример #12
0
 def get(self, organization, repo):
     super(StaticLogsHandler, self).get()
     app_name = App.make_app_name(organization, repo)
     app = yield self._get_app(app_name)
     time_string = datetime.datetime.strftime(app.last_build_time,
                                              LogSettings.TIME_FORMAT)
     filtered = self.get_query_argument('filtered',
                                        default='false').lower() == 'true'
     logs = yield self._get_app_logs(app_name, time_string, filtered)
     self.write({"logs": logs})
Пример #13
0
 def get(self, organization, repo):
     # if the app is still building, return an error. If the app is built, deploy it and return
     # the redirect url
     super(GithubHandler, self).get()
     app_name = App.make_app_name(organization, repo)
     app = yield self._get_app(app_name)
     if app and app.build_state == App.BuildState.COMPLETED:
         redirect_url = yield self._deploy_app(app, "single-node")
         self.write({"redirect_url": redirect_url})
     else:
         self.set_status(404)
         self.write({"error": "no app available to deploy"})
Пример #14
0
 def get(self, organization, repo):
     # if the app is still building, return an error. If the app is built, deploy it and return
     # the redirect url
     super(GithubHandler, self).get()
     app_name = App.make_app_name(organization, repo)
     app = yield self._get_app(app_name)
     if app and app.build_state == App.BuildState.COMPLETED:
         redirect_url = yield self._deploy_app(app, "single-node")
         self.write({"redirect_url": redirect_url})
     else:
         self.set_status(404)
         self.write({"error": "no app available to deploy"})
Пример #15
0
 def run(self):
     app = App.get_app(self._app_name)
     time_string = datetime.datetime.strftime(app.last_build_time, LogSettings.TIME_FORMAT)
     self._stream = AppLogStreamer(self._app_name, time_string).get_stream()
     while not self._stopped:
         time.sleep(0.05)
         try: 
             msg = self._stream.next()
             if msg:
                 self._ioloop.add_callback(self._handler.write_message, msg)
         except StopIteration:
             self.stop()
Пример #16
0
def build_app(spec, log_dir, preload=False):
    name = spec["name"]
    sys.stdout = open(os.path.join(log_dir,
                                   name + "-" + str(os.getpid()) + ".out"),
                      "w",
                      buffering=0)
    sys.stderr = open(os.path.join(log_dir,
                                   name + "-" + str(os.getpid()) + ".err"),
                      "w",
                      buffering=0)
    app = App.get_app(name)
    print("In build_app")
    if app and app.build_state == App.BuildState.BUILDING:
        print(
            "App {} already building. Wait for build to complete before resubmitting."
            .format(name))
        return
    new_app = App.create(spec)
    try:
        new_app.build(preload=preload)
    except Exception as e:
        # the "catch-all" clause
        print("Could not build app {}: {}".format(new_app.name, e))
        App.index.update_build_state(App.BuildState.FAILED)
Пример #17
0
 def run(self):
     app = App.get_app(self._app_name)
     time_string = datetime.datetime.strftime(app.last_build_time,
                                              LogSettings.TIME_FORMAT)
     self._stream = AppLogStreamer(self._app_name,
                                   time_string).get_stream()
     while not self._stopped:
         time.sleep(0.05)
         try:
             msg = self._stream.next()
             if msg:
                 self._ioloop.add_callback(self._handler.write_message,
                                           msg)
         except StopIteration:
             self.stop()
Пример #18
0
 def post(self, organization, repo):
     # if the spec is properly formed, create/build the app
     super(GithubBuildHandler, self).post()
     print("request.body: {}".format(self.request.body))
     spec = json.loads(self.request.body)
     if self._is_malformed(spec):
         self.set_status(400)
         self.write({"error": "malformed app specification"})
     else:
         try:
             spec["name"] = App.make_app_name(organization, repo).lower()
             spec["repo"] = "https://www.github.com/{0}/{1}".format(organization, repo)
             build_queue.put(spec)
             self.write({"success": "app submitted to build queue"})
         except Queue.Full:
             self.write({"error": "build queue full"})
Пример #19
0
 def post(self, organization, repo):
     # if the spec is properly formed, create/build the app
     super(GithubBuildHandler, self).post()
     print("request.body: {}".format(self.request.body))
     spec = json.loads(self.request.body)
     if self._is_malformed(spec):
         self.set_status(400)
         self.write({"error": "malformed app specification"})
     else:
         try:
             spec["name"] = App.make_app_name(organization, repo).lower()
             spec["repo"] = "https://www.github.com/{0}/{1}".format(
                 organization, repo)
             build_queue.put(spec)
             self.write({"success": "app submitted to build queue"})
         except Queue.Full:
             self.write({"error": "build queue full"})
Пример #20
0
 def get(self):
     super(AppsHandler, self).get()
     apps = App.get_app()
     self.write({"apps": [app.name for app in apps]})
Пример #21
0
 def _get_apps(self):
     return App.get_app()
Пример #22
0
 def _get_app(self, app_name):
     return App.get_app(app_name)
Пример #23
0
 def _get_app(self, app_name):
     return App.get_app(app_name)
Пример #24
0
 def _get_apps(self):
     return App.get_app()
Пример #25
0
 def get(self):
     super(AppsHandler, self).get()
     apps = App.get_app()
     self.write({"apps": [app.name for app in apps]})
Пример #26
0
 def _configure_app_loggers(self):
     make_dir(LogSettings.APPS_DIRECTORY)
     apps = App.get_app()
     for app in apps:
         if not app.name in self._app_loggers:
             self._make_app_loggers(app.name)