Skip to content

Commit 29152e8

Browse files
authored
Update sync.py
Adding --timeout flag and changed the default from 10 to 60
1 parent 1bb0f41 commit 29152e8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sync.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async def upload_extension_attribute(session, url, user, passwd, ext_attr, semap
127127
with open(join(mypath, 'extension_attributes', ext_attr, script_file[0]), 'r') as f:
128128
data=f.read()
129129
async with semaphore:
130-
with async_timeout.timeout(10):
130+
with async_timeout.timeout(args.timeout):
131131
template = await get_ea_template(session, url, user, passwd, ext_attr)
132132
async with session.get(url + '/JSSResource/computerextensionattributes/name/' + template.find('name').text,
133133
auth=auth, headers=headers) as resp:
@@ -157,7 +157,7 @@ async def get_ea_template(session, url, user, passwd, ext_attr):
157157
with open(join(mypath, 'extension_attributes', ext_attr, xml_file[0]), 'r') as file:
158158
template = ET.fromstring(file.read())
159159
except IndexError:
160-
with async_timeout.timeout(10):
160+
with async_timeout.timeout(args.timeout):
161161
headers = {'Accept': 'application/xml','Content-Type':'application/xml'}
162162
async with session.get(url + '/JSSResource/computerextensionattributes/name/' + ext_attr,
163163
auth=auth, headers=headers) as resp:
@@ -211,7 +211,7 @@ async def upload_script(session, url, user, passwd, script, semaphore):
211211
with open(join(mypath, 'scripts', script, script_file[0]), 'r') as f:
212212
data=f.read()
213213
async with semaphore:
214-
with async_timeout.timeout(10):
214+
with async_timeout.timeout(args.timeout):
215215
template = await get_script_template(session, url, user, passwd, script)
216216
async with session.get(url + '/JSSResource/scripts/name/' + template.find('name').text,
217217
auth=auth, headers=headers) as resp:
@@ -235,7 +235,7 @@ async def get_script_template(session, url, user, passwd, script):
235235
with open(join(mypath, 'scripts', script, xml_file[0]), 'r') as file:
236236
template = ET.fromstring(file.read())
237237
except IndexError:
238-
with async_timeout.timeout(10):
238+
with async_timeout.timeout(args.timeout):
239239
headers = {'Accept': 'application/xml','Content-Type':'application/xml'}
240240
async with session.get(url + '/JSSResource/scripts/name/' + script,
241241
auth=auth, headers=headers) as resp:
@@ -269,6 +269,7 @@ async def main(args):
269269
parser.add_argument('--username')
270270
parser.add_argument('--password')
271271
parser.add_argument('--limit', type=int, default=25)
272+
parser.add_argument('--timeout', type=int, default=60)
272273
parser.add_argument('--verbose', action='store_true')
273274
parser.add_argument('--do_not_verify_ssl', action='store_false')
274275
parser.add_argument('--update_all', action='store_true')

0 commit comments

Comments
 (0)