:art: Update qiniuonce

huangqimin001 11 mēneši atpakaļ
vecāks
revīzija
0e34740f92
1 mainītis faili ar 19 papildinājumiem un 16 dzēšanām
  1. 19 16
      commands/management/commands/qiniuonce.py

+ 19 - 16
commands/management/commands/qiniuonce.py

@@ -10,19 +10,22 @@ from utils.qiniucdn import upload_file_path
10 10
 class Command(CompatibilityBaseCommand):
11 11
     def handle(self, *args, **options):
12 12
 
13
-        files = os.listdir('media/file')
14
-
15
-        for file in files:
16
-            print(file)
17
-            ext = file.split('.')[-1]
18
-            if not ext:
19
-                continue
20
-            if ext.lower() not in ['jpg', 'jpeg', 'png']:
21
-                continue
22
-            try:
23
-                file_path = 'media/file/{}'.format(file)
24
-                if os.path.exists(file_path):
25
-                    upload_file_path(file_path, key=file, bucket='tamron')
26
-                    os.remove(file_path)
27
-            except Exception:
28
-                pass
13
+        dirs = ['media/file', 'media/user/complement_code']
14
+
15
+        for dir in dirs:
16
+            files = os.listdir(dir)
17
+
18
+            for file in files:
19
+                print(file)
20
+                ext = file.split('.')[-1]
21
+                if not ext:
22
+                    continue
23
+                if ext.lower() not in ['jpg', 'jpeg', 'png']:
24
+                    continue
25
+                try:
26
+                    file_path = 'media/file/{}'.format(file)
27
+                    if os.path.exists(file_path):
28
+                        upload_file_path(file_path, key=file, bucket='tamron')
29
+                        os.remove(file_path)
30
+                except Exception:
31
+                    pass