create pics.json
This commit is contained in:
		
							parent
							
								
									882fe5e8a3
								
							
						
					
					
						commit
						779c3f09d1
					
				| 
						 | 
					@ -1 +1,9 @@
 | 
				
			||||||
{ "original": "../pictures", "webp": "../webp1", "quality": 90, "container": "tmp", "remote": "", "local": "../pictures", "ignore": []}
 | 
					{
 | 
				
			||||||
 | 
					    "original": "../pictures",
 | 
				
			||||||
 | 
					    "webp": "../webp",
 | 
				
			||||||
 | 
					    "quality": 90,
 | 
				
			||||||
 | 
					    "container": "tianyi-random",
 | 
				
			||||||
 | 
					    "remote": "",
 | 
				
			||||||
 | 
					    "local": "../webp",
 | 
				
			||||||
 | 
					    "ignore": []
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										8
									
								
								sync.py
								
								
								
								
							
							
						
						
									
										8
									
								
								sync.py
								
								
								
								
							| 
						 | 
					@ -3,7 +3,9 @@ from azure.identity import DefaultAzureCredential
 | 
				
			||||||
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
 | 
					from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
 | 
				
			||||||
import argparse
 | 
					import argparse
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
defaults=json.load(open('defaults.json'))
 | 
					defaults=json.load(open('defaults.json'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
parser = argparse.ArgumentParser()
 | 
					parser = argparse.ArgumentParser()
 | 
				
			||||||
parser.add_argument('--container', help='Name of the container', default=defaults['container'])
 | 
					parser.add_argument('--container', help='Name of the container', default=defaults['container'])
 | 
				
			||||||
parser.add_argument('--remote', help='Path to the remote images', default=defaults['remote'])
 | 
					parser.add_argument('--remote', help='Path to the remote images', default=defaults['remote'])
 | 
				
			||||||
| 
						 | 
					@ -12,6 +14,8 @@ parser.add_argument('--ignore', help='Files to ignore', default=defaults['ignore
 | 
				
			||||||
parser.add_argument('--overwrite', help='Overwrite existing images', action='store_true')
 | 
					parser.add_argument('--overwrite', help='Overwrite existing images', action='store_true')
 | 
				
			||||||
args=parser.parse_args()
 | 
					args=parser.parse_args()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pics=[]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if args.remote!='' and args.remote[-1] != '/':
 | 
					if args.remote!='' and args.remote[-1] != '/':
 | 
				
			||||||
    args.remote += '/'
 | 
					    args.remote += '/'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +28,7 @@ try:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for root,fir,files in os.walk(args.local):
 | 
					    for root,fir,files in os.walk(args.local):
 | 
				
			||||||
        for file in files:
 | 
					        for file in files:
 | 
				
			||||||
 | 
					            pics.append(file)
 | 
				
			||||||
            if file in args.ignore:
 | 
					            if file in args.ignore:
 | 
				
			||||||
                print("ignored: " + file)
 | 
					                print("ignored: " + file)
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
| 
						 | 
					@ -49,3 +54,6 @@ try:
 | 
				
			||||||
except Exception as ex:
 | 
					except Exception as ex:
 | 
				
			||||||
    print('Exception:')
 | 
					    print('Exception:')
 | 
				
			||||||
    print(ex)
 | 
					    print(ex)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					finally:
 | 
				
			||||||
 | 
					    json.dump(pics, open('pics.json', 'w'))
 | 
				
			||||||
		Loading…
	
		Reference in New Issue