Browse Source

update waller.py

Alenx 6 years ago
parent
commit
bd307253ff
2 changed files with 21 additions and 5 deletions
  1. 13 5
      walle/service/deployer.py
  2. 8 0
      walle/service/utils.py

+ 13 - 5
walle/service/deployer.py

@@ -18,7 +18,7 @@ from walle.model.record import RecordModel
 from walle.model.task import TaskModel
 from walle.service.code import Code
 from walle.service.error import WalleError
-from walle.service.utils import color_clean
+from walle.service.utils import color_clean, suffix_format
 from walle.service.utils import excludes_format
 from walle.service.notice import Notice
 from walle.service.waller import Waller
@@ -196,12 +196,20 @@ class Deployer:
             with self.localhost.cd(self.local_codebase + self.release_version):
                 result = self.localhost.local(command, wenv=self.config())
 
-        # 压缩打包
+        # # 压缩打包
+        # # 排除文件发布
+        # self.release_version_tar = '%s.tgz' % (self.release_version)
+        # with self.localhost.cd(self.local_codebase):
+        #     excludes = excludes_format(self.project_info['excludes'])
+        #     command = 'tar zcf  %s %s %s' % (self.release_version_tar, excludes, self.release_version)
+        #     result = self.localhost.local(command, wenv=self.config())
+
+        # 指定文件发布
         self.release_version_tar = '%s.tgz' % (self.release_version)
-        with self.localhost.cd(self.local_codebase):
-            excludes = excludes_format(self.project_info['excludes'])
+        with self.local.cd(self.local_codebase):
+            excludes = suffix_format(self.dir_codebase_project, self.project_info['excludes'])
             command = 'tar zcf  %s %s %s' % (self.release_version_tar, excludes, self.release_version)
-            result = self.localhost.local(command, wenv=self.config())
+            result = self.local.run(command, wenv=self.config())
 
     def prev_release(self, waller):
         '''

+ 8 - 0
walle/service/utils.py

@@ -2,6 +2,7 @@
 """Helper utilities and decorators."""
 from __future__ import print_function
 
+import fnmatch
 import sys
 import time
 from datetime import datetime
@@ -86,3 +87,10 @@ def excludes_format(excludes_string):
         return ''
     excludes = ' --exclude='.join(excludes)
     return ' --exclude=' + excludes
+
+
+# 指定发布文件,支持模糊匹配,如:*.war
+def suffix_format(path, suffix_file):
+    for suffix_file in os.listdir('%s' % path):
+        if fnmatch.fnmatch(suffix_file, '%s' % suffix_file):
+            return suffix_file