예제 #1
0
파일: deploy.py 프로젝트: TheSophon/sophon
    def post(self):
        taskname = self.get_argument("taskname")
        repo_uri = self.get_argument("repo_uri")
        entry_point = self.get_argument("entry_point")
        hosts = json.loads(self.get_argument("hosts"))

        username = self.get_secure_cookie("username")
        user_id = UserMeta.query.filter_by(username=username).first().id

        deploy_item = DeployMeta(taskname=taskname, user_id=user_id,
                                 repo_uri=repo_uri, entry_point=entry_point,
                                 hosts=hosts)
        session.add(deploy_item)
        session.commit()
        session.close()

        do_deploy(deploy_id=deploy_item.id,
                  entry_point=entry_point, user="******",
                  hosts=hosts, repo_uri=repo_uri)

        self.write({
            deploy_item.id: {
                "Taskname": deploy_item.taskname,
                "Status": deploy_item.status,
                "Created": created2str(created=deploy_item.created)
            }
        })
예제 #2
0
파일: deploy.py 프로젝트: TheSophon/sophon
 def get(self):
     result = DeployMeta.get_all_deploy_summary()
     for key in result.keys():
         result[key]["Created"] = created2str(
             result[key]["Created"]
         )
     self.write(result)
예제 #3
0
    def test_created2str(self, _time):
        _localtime = mock.Mock()
        _time.localtime.return_value = _localtime
        _time.strftime.return_value = "sample_time"

        result = created2str(123)

        _time.localtime.called_once_with()
        _time.strftime.called_once_with(
            "%d %b %Y %H:%M:%S", _localtime
        )
        self.assertEqual(result, "sample_time")
예제 #4
0
파일: deploy.py 프로젝트: TheSophon/sophon
 def get(self, deploy_id):
     result = DeployMeta.get_deploy_item_by_id(deploy_id=int(deploy_id))
     result.update({
         "Created": created2str(created=result["Created"])
     })
     self.write(result)