File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+
3+ """
4+ Export from Property Lists files
5+ """
6+
7+ from os import walk , path
8+ from plistlib import load
9+ from requests import put
10+ from cryptic import b64_ascii
11+
12+ PLIST_DIR = "/tmp/plists"
13+ URL = ""
14+ HEADERS = {"X-API-Key" : "xyz" }
15+
16+ if __name__ == "__main__" :
17+ devices = []
18+ for root , dirs , files in walk (PLIST_DIR ):
19+ for file in files :
20+ if file .endswith (".plist" ):
21+ plist_path = path .join (root , file )
22+ print ("Reading" , plist_path )
23+ with open (plist_path , "rb" ) as plist :
24+ for device in load (plist ):
25+ devices .append (
26+ {
27+ "name" : device ["name" ],
28+ "privateKey" : b64_ascii (device ["privateKey" ]),
29+ }
30+ )
31+ print (devices )
32+ if URL .startswith ("http" ):
33+ response = put (URL , headers = HEADERS , json = devices , timeout = 60 )
34+ print ("status_code:" , response .status_code )
You can’t perform that action at this time.
0 commit comments