-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLastModifi_Jfrog.py
More file actions
24 lines (24 loc) · 867 Bytes
/
LastModifi_Jfrog.py
File metadata and controls
24 lines (24 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import urllib.request, json
import sys, collections
from datetime import datetime
file = open(sys.argv[1], "r")
for l in file:
line = l
line = line.replace("artifactory/", "artifactory/api/storage/")
file.close()
dict = {}
dictsort = {}
with urllib.request.urlopen(line) as url:
data = json.loads(url.read().decode())
print(data)
for name in data["children"] :
art_name = name["uri"].strip('/')
url2 = urllib.request.urlopen(line.strip('\n') + art_name.strip('\n'))
data2 = json.loads(url2.read().decode())
newdt = datetime.strptime(data2["lastModified"], "%Y-%m-%dT%H:%M:%S.%fZ")
dict.update({newdt : art_name})
dictsort = sorted(dict.keys())
print(dictsort[-1])
urlfile = open(sys.argv[1], "w")
urlfile.write(line.strip('\n').replace("/api/storage", "") + dict[dictsort[-1]].strip('\n'))
urlfile.close()