]>
Commit | Line | Data |
---|---|---|
ca5df2cb VK |
1 | import shutil |
2 | import os | |
3 | import json | |
4 | import grp | |
5 | import pwd | |
6 | ||
7 | src = "/uio/kant/usit-ft-u1/vegarko/git/korvald/downloads/completed/" | |
8 | fx = "/uio/kant/usit-ft-u1/vegarko/git/korvald/tsd/" | |
9 | ||
10 | ||
11 | def run(record): | |
12 | json_file = record+".json" | |
13 | video = record+".mp4" | |
14 | ||
15 | with open(src+json_file) as f: | |
16 | data = json.load(f) | |
17 | pnum = data['recordedBy'][:3] | |
18 | folder = data['roomName'] | |
19 | ||
20 | username = data['recordedBy'][:-4] | |
21 | dest = fx+pnum+"/durable/"+folder+"/" | |
22 | ||
23 | shutil.move(src+json_file, dest+json_file) | |
24 | shutil.move(src+video, dest+video) | |
25 | ||
26 | try: | |
27 | gid = grp.getgrnam(pnum+"-import-vidyo-group").gr_gid | |
28 | except KeyError as e: | |
29 | print "Group {}-import-vidyo-group does not exist: {}".format(pnum, e) | |
30 | ||
31 | try: | |
32 | uid = pwd.getpwnam(username).pw_uid | |
33 | except KeyError as e: | |
34 | print "User {} does not exist: {}".format(username, e) | |
35 | ||
36 | # os.chmod(dest+json_file, 0770) | |
37 | # os.chmod(dest+video, 0770) | |
38 | # os.chown(dest+json_file, uid, gid) | |
39 | # os.chown(dest+video, uid, gid) | |
40 | ||
41 | ||
42 | if __name__ == "__main__": | |
43 | for f in os.listdir(src): | |
44 | if f.endswith(".json"): | |
45 | run(f[:-5]) |