-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks_dams_netx.py
106 lines (76 loc) · 3.05 KB
/
tasks_dams_netx.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
'''
dams-netx task list
'''
from datetime import datetime
import logging
import os
import time
import prep_emu_media
import check_netxio_errors
import prep_emu_xml
import prep_pathadd
import netx_add_folder
import netx_remove_asset
import netx_update_collections
import netx_remove_collection
from utils import setup
def main():
'''Run through dams-netx sync tasks'''
today = str(datetime.today())[:10]
live_or_test = 'LIVE'
# Start logs
setup.start_log_dams_netx(config=None, cmd_args=[live_or_test, today])
config = setup.get_config_dams_netx(live_or_test)
# # # # Start dams-netx steps:
# 1 - Prep media files
logging.info(' - - prep_emu_media - %s - %s - - -', live_or_test, today)
prep_emu_media.main(live_or_test=live_or_test, input_date=today)
# 2 - Run NetXIO to ingest media files
if live_or_test == 'LIVE':
netx_io_props = config['NETXIO_PROPS']
else:
netx_io_props = config['TEST_NETXIO_PROPS']
netx_io_jar = config['NETXIO_JAR']
netx_io = f'sudo java -Xms512M -Xmx2048M -cp "{netx_io_jar}" com.netxposure.external.client.io.NetxIO -config "{netx_io_props}"'
logging.info('NETX_IO: %s', netx_io)
os.system(netx_io)
time.sleep(1)
# 3 - Update folder permissions
update_folder_permission = "cd /home/kwebbink/NetxIO/NetxIO_workfiles/ && sudo chown -R kwebbink:10513 lostandfound"
logging.info('Edit Folder permission: %s', update_folder_permission)
os.system(update_folder_permission)
time.sleep(1)
# 4 - (dams-netx) Check for NetXIO lostandfound
logging.info(' - - check_netxio_errors - - -')
check_netxio_errors.main(live_or_test)
# 5 - (dams-netx) Prep XML for DSS
logging.info(' - - prep_emu_xml - - -')
prep_emu_xml.main(live_or_test, today)
# 6 - (NetXIO) Run NexIO DSS-xml-file import
if live_or_test == 'LIVE':
netxio_dss_props = config['NETXIO_DSS_PROPS']
else:
netxio_dss_props = config['TEST_NETXIO_DSS_PROPS']
netx_io_dss = f'sudo java -Xms512M -Xmx2048M -cp "{netx_io_jar}" com.netxposure.external.client.io.NetxIO -config "{netxio_dss_props}"'
logging.info('NETX_IO_DSS: %s', netx_io_dss)
os.system(netx_io_dss)
time.sleep(1)
# 7 - (dams-netx) Prep pathAdd folder-update
logging.info(' - - prep_pathadd - - -')
prep_pathadd.main(live_or_test, today)
# 8 - (dams-netx) Update folders via NetX API
logging.info(' - - netx_add_folder - - -')
netx_add_folder.main(live_or_test)
# 9 - (dams-netx) Move unpublished/deleted assets to "Remove_from_NetX" folder
logging.info(' - - netx_remove_asset - - -')
netx_remove_asset.main(live_or_test, today)
# 10 - (dams-netx) Update Groups via NetX API
logging.info(' - - netx_update_collections - - -')
netx_update_collections.main(live_or_test, today)
# 11 (dams-netx) Remove unpublished/deleted collections
logging.info(' - - netx_remove_collection - - -')
netx_remove_collection.main(live_or_test, today)
# Stop logs
setup.stop_log_dams_netx()
if __name__ == '__main__':
main()