zhongrj
2025-11-25 b89962006164a462404b79a738bee8cbb6d7fe7e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
from django.core.management.base import BaseCommand
from django.core.management import call_command
from app.models import Project
from webodm import settings
 
class Command(BaseCommand):
    requires_system_checks = []
 
    def add_arguments(self, parser):
        parser.add_argument("action", type=str, choices=['mediapattern'])
        parser.add_argument("--skip-images", action='store_true', required=False, help="Skip images")
        parser.add_argument("--skip-no-quotas", action='store_true', required=False, help="Skip directories owned by users with no quota (0)")
        parser.add_argument("--skip-tiles", action='store_true', required=False, help="Skip tiled assets which can be regenerated from other data")
        parser.add_argument("--skip-legacy-textured-models", action='store_true', required=False, help="Skip textured models in OBJ format")
        
        super(Command, self).add_arguments(parser)
 
    def handle(self, **options):
        if options.get('action') == 'mediapattern':
            print("# BorgBackup pattern file for media directory")
            print("# Generated with WebODM")
            print("")
 
            print("# Skip anything but project folder")
            for d in os.listdir(settings.MEDIA_ROOT):
                if d != "project":
                    print(f"! {d}")
            
            if options.get('skip_no_quotas'):
                skip_projects = Project.objects.filter(owner__profile__quota=0).order_by('id')
            else:
                skip_projects = []
 
            print("")
            print("# Skip projects")
            for sp in skip_projects:
                print("- " + os.path.join("project", str(sp.id)))
 
            if options.get('skip_images'):
                print("")
                print("# Skip images/other files")
                print("- project/*/task/*/*.*")
            
            if options.get('skip_tiles'):
                print("")
                print("# Skip entwine/potree folders")
                print("! project/*/task/*/assets/entwine_pointcloud")
                print("! project/*/task/*/assets/potree_pointcloud")
                print("")
                print("# Skip tiles folders")
                print("! project/*/task/*/assets/*_tiles")
            
            print("# Skip data")
            print("! project/*/task/*/data")
 
            if options.get('skip_legacy_textured_models'):
                print("")
                print("# Skip OBJ texture model files")
                print("+ project/*/task/*/assets/odm_texturing/*.glb")
                print("- project/*/task/*/assets/odm_texturing")