Ver código fonte

walle 2.0 alpha - 支持python 3.5+

walle 6 anos atrás
pai
commit
dd486b27c6

+ 6 - 6
walle/api/api.py

@@ -86,7 +86,7 @@ class SecurityResource(ApiResource):
         self.action = 'delete'
         is_allow = AccessRbac.is_allow(action=self.action, controller=self.controller)
         if not is_allow:
-            self.render_json(code=403, message=u'无操作权限')
+            self.render_json(code=403, message='无操作权限')
             # abort(403)
             pass
         pass
@@ -96,7 +96,7 @@ class SecurityResource(ApiResource):
         self.action = 'put'
         is_allow = AccessRbac.is_allow(action=self.action, controller=self.controller)
         if not is_allow:
-            self.render_json(code=403, message=u'无操作权限')
+            self.render_json(code=403, message='无操作权限')
             # abort(403)
             pass
         pass
@@ -114,10 +114,10 @@ class SecurityResource(ApiResource):
 
     def validator(self):
         if not AccessRbac.is_login():
-            return self.render_json(code=1000, message=u'请先登录')
+            return self.render_json(code=1000, message='请先登录')
 
         if not AccessRbac.is_allow(action=self.action, controller=self.controller):
-            return self.render_json(code=1001, message=u'无操作权限')
+            return self.render_json(code=1001, message='无操作权限')
 
 
     @staticmethod
@@ -125,7 +125,7 @@ class SecurityResource(ApiResource):
         @wraps(func)
         def is_enable(*args, **kwargs):
             if current_user.role_info.name != 'super':
-                return ApiResource.render_json(code=403, message=u'无操作权限')
+                return ApiResource.render_json(code=403, message='无操作权限')
             current_app.logger.info("user is login: %s" % (current_user.is_authenticated))
             current_app.logger.info("args: %s kwargs: %s" % (args, kwargs))
             return func(*args, **kwargs)
@@ -137,7 +137,7 @@ class SecurityResource(ApiResource):
         @wraps(func)
         def is_enable(*args, **kwargs):
             if current_user.role_info.name not in ['super', 'master']:
-                return ApiResource.render_json(code=403, message=u'无操作权限')
+                return ApiResource.render_json(code=403, message='无操作权限')
             current_app.logger.info("user is login: %s" % (current_user.is_authenticated))
             current_app.logger.info("args: %s kwargs: %s" % (args, kwargs))
             return func(*args, **kwargs)

+ 1 - 1
walle/api/task.py

@@ -156,7 +156,7 @@ class TaskAPI(SecurityResource):
             raise WalleError(code=Code.rollback_error)
 
         task['id'] = None
-        task['name'] = task['name'] + u' - 回滚此次上线'
+        task['name'] = task['name'] + ' - 回滚此次上线'
         task['link_id'] = task['ex_link_id']
         task['ex_link_id'] = ''
         task['is_rollback'] = 1

+ 2 - 2
walle/api/user.py

@@ -95,7 +95,7 @@ class UserAPI(SecurityResource):
             # add user
             user = UserModel().add(user_info)
             # send an email
-            message = u"""Hi, %s
+            message = """Hi, %s
                     <br> <br>Welcome to walle, it cost a lot of time and lock to meet you, enjoy it : )
                     <br><br>name: %s<br>password: %s""" \
                               % (user.username, user.email, form.password.data)
@@ -161,7 +161,7 @@ class UserAPI(SecurityResource):
             },
         }
         ret = []
-        for (key, value) in table.items():
+        for (key, value) in list(table.items()):
             value['key'] = key
             if key in filter:
                 value['value'] = filter[key]

+ 1 - 1
walle/model/project.py

@@ -114,7 +114,7 @@ class ProjectModel(SurrogatePK, Model):
 
         ServerModel = model.server.ServerModel
         server_ids = project_info['server_ids']
-        project_info['servers_info'] = ServerModel.fetch_by_id(map(int, server_ids.split(',')))
+        project_info['servers_info'] = ServerModel.fetch_by_id(list(map(int, server_ids.split(','))))
         return project_info
 
     def add(self, *args, **kwargs):

+ 1 - 1
walle/model/task.py

@@ -129,7 +129,7 @@ class TaskModel(SurrogatePK, Model):
         task = data.to_json()
         ProjectModel = model.project.ProjectModel
         project = ProjectModel().item(task['project_id'])
-        task['project_name'] = project['name'] if project else u'未知项目'
+        task['project_name'] = project['name'] if project else '未知项目'
         task['project_info'] = project
         return task
 

+ 3 - 3
walle/model/user.py

@@ -173,7 +173,7 @@ class UserModel(UserMixin, SurrogatePK, Model):
         if not spaces and current_user.role != SUPER:
             raise WalleError(Code.space_empty)
 
-        default_space = spaces.keys()[0]
+        default_space = list(spaces.keys())[0]
 
         # 2.第一次登录无空间
         if not current_user.last_space:
@@ -183,7 +183,7 @@ class UserModel(UserMixin, SurrogatePK, Model):
             session['space_info'] = spaces[session['space_id']]
 
         # 3.空间权限有修改(上次登录的空格没有权限了)
-        if current_user.last_space not in spaces.keys():
+        if current_user.last_space not in list(spaces.keys()):
             current_user.last_space = default_space
 
 
@@ -193,7 +193,7 @@ class UserModel(UserMixin, SurrogatePK, Model):
 
         session['space_id'] = current_user.last_space
         session['space_info'] = spaces[current_user.last_space]
-        session['space_list'] = spaces.values()
+        session['space_list'] = list(spaces.values())
 
     @classmethod
     def avatar_url(cls, avatar):

+ 6 - 6
walle/service/deployer.py

@@ -329,9 +329,9 @@ class Deployer:
             result = waller.run('id', exception=False, wenv=self.config())
             if result.failed:
                 errors.append({
-                    'title': u'远程目标机器免密码登录失败',
-                    'why': u'远程目标机器:%s 错误:%s' % (server_info['host'], result.stdout),
-                    'how': u'在宿主机中配置免密码登录,把宿主机用户%s的~/.ssh/ssh_rsa.pub添加到远程目标机器用户%s的~/.ssh/authorized_keys。了解更多:http://walle-web.io/docs/troubleshooting.html' % (
+                    'title': '远程目标机器免密码登录失败',
+                    'why': '远程目标机器:%s 错误:%s' % (server_info['host'], result.stdout),
+                    'how': '在宿主机中配置免密码登录,把宿主机用户%s的~/.ssh/ssh_rsa.pub添加到远程目标机器用户%s的~/.ssh/authorized_keys。了解更多:http://walle-web.io/docs/troubleshooting.html' % (
                     pwd.getpwuid(os.getuid())[0], server_info['host']),
                 })
 
@@ -340,9 +340,9 @@ class Deployer:
             result = waller.run(command, exception=False, wenv=self.config())
             if result.stdout == 'false':
                 errors.append({
-                    'title': u'远程目标机器webroot不能是已建好的目录',
-                    'why': u'远程目标机器%s webroot不能是已存在的目录,必须为软链接,你不必新建,walle会自行创建。' % (server_info['host']),
-                    'how': u'手工删除远程目标机器:%s webroot目录:%s' % (server_info['host'], self.project_info['target_root']),
+                    'title': '远程目标机器webroot不能是已建好的目录',
+                    'why': '远程目标机器%s webroot不能是已存在的目录,必须为软链接,你不必新建,walle会自行创建。' % (server_info['host']),
+                    'how': '手工删除远程目标机器:%s webroot目录:%s' % (server_info['host'], self.project_info['target_root']),
                 })
 
         # remote release directory

+ 1 - 1
walle/service/notice/dingding.py

@@ -33,7 +33,7 @@ class Dingding(Notice):
             "msgtype": "markdown",
             "markdown": {
                 "title": "上线单通知",
-                "text": u"""#### ![screenshot](http://walle-web.io/dingding.jpg) %s %s  \n> **项目**:%s \n
+                "text": """#### ![screenshot](http://walle-web.io/dingding.jpg) %s %s  \n> **项目**:%s \n
                 > **任务**:%s \n
                 > **分支**:%s \n
                 > **版本**:%s \n """ % (

+ 1 - 1
walle/service/notice/email.py

@@ -27,7 +27,7 @@ class Email(Notice):
             'is_branch',
         @return:
         '''
-        message = u""" %s %s 
+        message = """ %s %s 
                 <br><br> <strong>项目</strong>:%s
                 <br><br> <strong>任务</strong>:%s
                 <br><br> <strong>分支</strong>:%s