-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEX VR Node.py
640 lines (474 loc) · 22.6 KB
/
EX VR Node.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
'''
##### **Quest 2 App Node** <sup>v1.4.5</sup>
___
_Requires [ADB Platform Tools](https://developer.android.com/tools/releases/platform-tools) to be installed at either `C:/content/` or an otherwise specified location in the node config._
Based on regular app node - but will only launch the application once both **the Headset is detected as a device by the computer**, and **the computer is detected as a valid Quest Link target by the headset.**
Will quit and restart application upon re-connection.
If Quest Link is unable to be launched, the headset will restart and begin the process again.
*Hint: Use the **Restart Application** Jump Control to relaunch the application without affecting the Quest!*
'''
from time import sleep
import itertools
# <parameters ---
param_ToolPath = Parameter({'title': 'ADB Platform Tools Path (ONLY SET IF THEY HAVE BEEN MOVED FROM C:\Content!)', 'required': True, 'schema': {'type': 'string', 'hint': '(e.g. "C:\Content\platform-tools")'},
'desc': 'The full path to the USB ADB platform-tools'})
param_AppPath = Parameter({'title': 'App. Path (required, executable name with or without path)', 'required': True, 'schema': {'type': 'string', 'hint': '(e.g. "C:\\MyApps\\myapp.exe" or "somethingOnThePath.exe")'},
'desc': 'The full path to the application executable'})
param_AppArgs = Parameter({'title': 'App. Args', 'schema': {'type': 'string', 'hint': 'e.g. --color BLUE --title What\'s\\ Your\\ Story? --subtitle \"Autumn Surprise!\"'},
'desc': 'Application arguments, space delimeted, backslash-escaped'})
param_AppWorkingDir = Parameter({'title': 'App. Working Dir.', 'schema': {'type': 'string', 'hint': 'e.g. c:\\temp'},
'desc': 'Full path to the working directory'})
param_PowerStateOnStart = Parameter({'title': 'Running state on Node Start', 'schema': {'type': 'string', 'enum': ['On', 'Off', '(previous)']},
'desc': 'What "power" state to start up in when the node itself starts, typically on boot'})
param_FeedbackFilters = Parameter({'title': 'Console Feedback filters', 'schema': {'type': 'array', 'items': {'type': 'object', 'properties': {
'type': {'type': 'string', 'enum': ['Include', 'Exclude'], 'order': 1},
'filter': {'type': 'string', 'order': 2}}}}})
# --->
# <signals ---
local_event_Running = LocalEvent({'group': 'Monitoring', 'schema': {'type': 'string', 'enum': ['On', 'Off']},
'desc': 'Locks to the actual running state of the application process'})
local_event_DesiredPower = LocalEvent({'group': 'Power', 'schema': {'type': 'string', 'enum': ['On', 'Off']},
'desc': 'The desired "power" (or running state), set using the action'})
local_event_Power = LocalEvent({'group': 'Power', 'schema': {'type': 'string', 'enum': ['On', 'Partially On', 'Off', 'Partially Off']},
'desc': 'The "effective" power state using Nodel power conventions taking into account actual and desired'})
local_event_LastStarted = LocalEvent({'group': 'Monitoring', 'schema': {'type': 'string'}, # holds dates
'desc': 'The last time the application started'})
local_event_FirstInterrupted = LocalEvent({'group': 'Monitoring', 'schema': {'type': 'string'}, # holds dates
'desc': 'The first time the process was "interrupted" (meaning it died prematurely)'})
local_event_LastInterrupted = LocalEvent({'group': 'Monitoring', 'schema': {'type': 'string'}, # holds dates
'desc': 'The last time the process was "interrupted" (meaning it died/stopped prematurely)'})
local_event_QuestLinkStatus = LocalEvent({'group': '', 'schema': {'type': 'string', 'enum': ['On', 'Off',]},
'desc': 'The status of the Quest Link connection'})
local_event_HeadsetConnectionStatus = LocalEvent({'group': '', 'schema': {'type': 'string', 'enum': ['On', 'Off',]},
'desc': 'The status of the physical headset connection'})
local_event_Battery = LocalEvent({'schema': {'type': 'string'},
'desc': 'Current Battery Level'})
# ensure these signals aggressively persist their values
# (by default Nodel is very relaxed which is not ideal for clients that may deal with more interruptions)
@after_main
def ensurePersistSignals():
def ensure(s): # variable capture requires separate function
s.addEmitHandler(lambda arg: s.persistNow())
for s in [ local_event_Running, local_event_DesiredPower, local_event_Power,
local_event_LastStarted, local_event_FirstInterrupted, local_event_LastInterrupted ]:
ensure(s)
# --- signals>
# <main ---
import os # path functions
import sys # launch environment info
timeouts = 0
QUESTTIMEOUT = 2
_resolvedAppPath = None # includes entire path
_platformTools = None
isXRLaunched = False
questconnected = False
global hasntdisconnected
hasntdisconnected = False
def main():
# App Path MUST be specified
if is_blank(param_AppPath):
console.error('No App. Path has been specified, nothing to do!')
_process.stop()
return
if is_blank(param_ToolPath):
console.info('ADB Platform Tools Path not set, presuming C:\content\platform-tools')
global _platformTools
_platformTools = "C:\\Content\\platform-tools\\" + "adb.exe"
if not os.path.isfile(_platformTools):
console.error('The ADB Platform Tools Path could not be found - [%s]' % _platformTools)
return
else:
global _platformTools
_platformTools = param_ToolPath + "adb.exe"
# check if a full path has been provided i.e. does it contain a backslash "\"
if os.path.sep in param_AppPath: # e.g.
global _resolvedAppPath
_resolvedAppPath = param_AppPath # use full path
quick_process([_platformTools, 'kill server'])
console.log("starting server")
quick_process([_platformTools, 'start server'])
quick_process([_platformTools, 'shell am force-stop com.oculus.vrshell'])
finishMain()
else:
# otherwise test the path using 'where.exe' (Windows) or 'which' (Linux)
# e.g. > where notepad
# < C:\Windows\System32\notepad.exe
# < C:\Windows\notepad.exe
def processFinished(arg):
global _resolvedAppPath
if arg.code == 0: # 'where.exe' succeeded
paths = arg.stdout.splitlines()
if len(paths or EMPTY) > 0:
_resolvedAppPath = paths[0]
if is_blank(_resolvedAppPath):
_resolvedAppPath = param_AppPath
finishMain()
# path not fully provided so use 'where' to scan PATH environment, (has to be done async)
whereCmd = 'where' if os.environ.get('windir') else 'which'
quick_process([ whereCmd, param_AppPath], finished=processFinished)
def finishMain():
if not os.path.isfile(_resolvedAppPath):
console.error('The App. Path could not be found - [%s]' % _resolvedAppPath)
return
# App Working Directory is optional
if not is_blank(param_AppWorkingDir) and not os.path.isdir(param_AppWorkingDir):
console.error('The App. working directory was specified but could not be found - [%s]' % param_AppWorkingDir)
return
# if not os.path.isfile()
# recommend that the process sandbox is used if one can't be found
# later versions of Nodel have the sandbox embedded (dynamically compiled)
usingEmbeddedSandbox = False
try:
from org.nodel.toolkit.windows import ProcessSandboxExecutable
usingEmbeddedSandbox = True
except:
usingEmbeddedSandbox = False
if not usingEmbeddedSandbox and os.environ.get('windir') and not (os.path.isfile('ProcessSandbox.exe') or os.path.exists('%s\\ProcessSandbox.exe' % sys.exec_prefix)):
console.warn('-- ProcessSandbox.exe NOT FOUND BUT RECOMMENDED --')
console.warn('-- It is recommended the Nodel Process Sandbox launcher is used on Windows --')
console.warn('-- The launcher safely manages applications process chains, preventing rogue or orphan behaviour --')
console.warn('--')
console.warn('-- Use Nodel jar v2.2.1.404 or later OR download ProcessSandbox.exe asset manually from https://github.com/museumsvictoria/nodel/releases/tag/v2.1.1-release391 --')
# ready to start, dump info
console.info('This node will issue a warning status if it detects application interruptions i.e. crashing or external party closing it (not by Node)')
if usingEmbeddedSandbox:
console.info('(embedded Process Sandbox detected and will be used)')
# start the list with the application path
cmdLine = [ _resolvedAppPath ]
# turn the arguments string into an array of args
if not is_blank(param_AppArgs):
cmdLine.extend(decodeArgList(param_AppArgs))
# use working directory is specified
if not is_blank(param_AppWorkingDir):
_process.setWorking(param_AppWorkingDir)
_process.setCommand(cmdLine)
console.info('Full command-line: [%s]' % ' '.join(cmdLine))
if param_PowerStateOnStart == 'On':
_process.stop()
local_event_DesiredPower.emit('Off')
call(lambda: lookup_local_action('Power').call('On'),5)
elif param_PowerStateOnStart == 'Off':
lookup_local_action('Power').call('Off')
else:
if local_event_DesiredPower.getArg() != 'On':
console.info('(desired power was previously off so not starting)')
_process.stop()
# otherwise process will start itself
def listDeviceOutput(arg):
#console.log(arg)
if len(arg.stdout.split()) > 4: #len counts from 1
console.info('Device Attached: %s' % arg.stdout.split()[4])
global questconnected
questconnected = True
local_event_HeadsetConnectionStatus.emit("On")
else:
global hasntdisconnected
global when
when = local_event_HeadsetConnectionStatus.getTimestamp().toString('E dd-MMM h:mm a')
local_event_HeadsetConnectionStatus.emit("Off")
console.error("No Devices Connected!")
hasntdisconnected = False
def Status_listDeviceOutput(arg):
global hasntdisconnected
if len(arg.stdout.split()) > 4: #len counts from 1
#console.info('Headset %s Found Again!' % arg.stdout.split()[4])
global questconnected
global firsttimedisconnect
questconnected = True
hasntdisconnected = True
local_event_HeadsetConnectionStatus.emit("On")
oculusCheck_timer.setInterval(10)
linkCheck_timer.start()
else:
global questconnected
local_event_HeadsetConnectionStatus.emit('Off')
if hasntdisconnected == True:
global when
when = local_event_HeadsetConnectionStatus.getTimestamp().toString('E dd-MMM h:mm a')
console.error("Lost connection to headset! Missing since: %s" % when)
hasntdisconnected = False
linkCheck_timer.stop()
questconnected = False
oculusCheck_timer.setInterval(5)
def firstLaunch(arg):
global questconnected
lookup_local_action('DisableProximity').call()
if "xrstreamingclient" in arg.stdout and questconnected == True:
local_event_QuestLinkStatus.emit('On')
isXRLaunched = True
console.log('Quest Link already on!')
call(lambda: lookup_local_action('LaunchApp').call(),5)
else:
lookup_local_action('EnableShell').call()
LaunchLink.call()
# --- main>
def oculusStartup():
quick_process([_platformTools, 'devices'], finished=listDeviceOutput)
# console.log("turn on airlink")
# quick_process([_platformTools, 'shell am broadcast -a "com.oculus.systemux.action.TOGGLE_AIRLINK" --ez enable_airlink 1'])
# sleep(5)
# console.log("turn off airlink")
# quick_process([_platformTools, 'shell am broadcast -a "com.oculus.systemux.action.TOGGLE_AIRLINK" --ez enable_airlink 0'])
console.info("Launching Quest Link")
#LaunchLink.call()
quick_process([_platformTools, 'shell "dumpsys activity activities | grep ResumedActivity"'], finished=firstLaunch)
# ----- Custom Quest Actions, also available as Jump Controls ------
@local_action({'group': 'Jump Controls', 'title': 'Launch Quest Link', 'order': next_seq()})
def LaunchLink():
quick_process([_platformTools, 'shell am start -S com.oculus.xrstreamingclient/.MainActivity'])
@local_action({'group': 'Jump Controls', 'title': 'Launch Application', 'order': next_seq()})
def LaunchApp():
if local_event_DesiredPower.getArg() == 'On':
#lookup_local_action('DisableProximity').call()
lookup_local_action('DisableShell').call()
lookup_local_action('KillShell').call()
call(lambda: lookup_local_action('EnableProximity').call(),5)
_process.start();
@local_action({'group': 'Jump Controls', 'title': 'Restart Application', 'order': next_seq()})
def RestartApp():
_process.stop();
call(lambda: lookup_local_action('LaunchApp').call(),3)
@local_action({'group': 'Jump Controls', 'title': 'Kill Shell', 'order': next_seq()})
def KillShell():
quick_process([_platformTools, 'shell am force-stop com.oculus.vrshell'])
@local_action({'group': 'Jump Controls', 'title': 'Disable Shell', 'order': next_seq()})
def DisableShell():
quick_process([_platformTools, 'shell pm disable-user com.oculus.vrshell'])
@local_action({'group': 'Jump Controls', 'title': 'Enable Shell', 'order': next_seq()})
def EnableShell():
quick_process([_platformTools, 'shell pm enable com.oculus.vrshell'])
quick_process([_platformTools, 'shell am start -S com.oculus.vrshell'])
@local_action({'group': 'Jump Controls', 'title': 'Disable Guardian', 'order': next_seq()})
def DisableGuardian():
quick_process([_platformTools, 'shell setprop debug.oculus.guardian_pause 1'])
@local_action({'group': 'Jump Controls', 'title': 'Disable Proximity', 'order': next_seq()})
def DisableProximity():
quick_process([_platformTools, 'shell am broadcast -a com.oculus.vrpowermanager.prox_close'])
@local_action({'group': 'Jump Controls', 'title': 'Enable Proximity', 'order': next_seq()})
def EnableProximity():
quick_process([_platformTools, 'shell am broadcast -a com.oculus.vrpowermanager.automation_disable'])
local_event_PowerOn = LocalEvent({ 'group': 'Power', 'title': 'On', 'order': next_seq(), 'schema': { 'type': 'boolean' }})
local_event_PowerOff = LocalEvent({ 'group': 'Power', 'title': 'Off', 'order': next_seq(), 'schema': { 'type': 'boolean' }})
@local_action({'group': 'Power', 'order': next_seq(), 'schema': {'type': 'string', 'enum': ['On', 'Off']},
'desc': 'Also used to clear First Interrupted warnings'})
def Power(arg):
# clear the first interrupted
local_event_FirstInterrupted.emit('')
if arg == 'On'and local_event_DesiredPower.getArg() == 'Off':
local_event_DesiredPower.emit('On')
#_process.start()
oculusStartup()
oculusCheck_timer.setInterval(10)
linkCheck_timer.setInterval(10)
oculusCheck_timer.start()
linkCheck_timer.start()
elif arg == 'Off':
local_event_DesiredPower.emit('Off')
oculusCheck_timer.stop()
linkCheck_timer.stop()
local_event_Running.emit('Off')
_process.stop()
@local_action({'group': 'Power', 'title': 'On', 'order': next_seq()})
def PowerOn():
Power.call('On')
@local_action({'group': 'Power', 'title': 'Off', 'order': next_seq()})
def PowerOff():
Power.call('Off')
@before_main
def sync_RunningEvent():
local_event_Running.emit('Off')
local_event_HeadsetConnectionStatus.emit('Off')
local_event_QuestLinkStatus.emit('Off')
def determinePower(arg):
desired = local_event_DesiredPower.getArg()
running = local_event_Running.getArg()
if desired == None: state = running
elif desired == running: state = running
else: state = 'Partially %s' % desired
local_event_Power.emit(running)
local_event_PowerOn.emit(running == 'On')
local_event_PowerOff.emit(running == 'Off')
@after_main
def bindPower():
local_event_Running.addEmitHandler(determinePower)
local_event_DesiredPower.addEmitHandler(determinePower)
# --- power>
# <process ---
def process_started():
console.info('application started!')
local_event_Running.emit('On')
local_event_LastStarted.emit(str(date_now()))
def process_stopped(exitCode):
console.info('application stopped! exitCode:%s' % exitCode)
nowStr = str(date_now()) # so exact timestamps are used
if local_event_DesiredPower.getArg() == 'On':
local_event_LastInterrupted.emit(nowStr)
# timestamp 'first interrupted' ONCE
if len(local_event_FirstInterrupted.getArg() or '') == 0:
local_event_FirstInterrupted.emit(nowStr)
local_event_Running.emit('Off')
# print out feedback from the console
def process_feedback(line):
inclusionFiltering = False
keep = None
for filterInfo in param_FeedbackFilters or []:
filterType = filterInfo.get('type')
ffilter = filterInfo.get('filter')
matches = ffilter in line
if filterType == 'Include':
inclusionFiltering = True
if matches:
keep = True
elif filterType == 'Exclude':
if matches:
keep = False
if keep == None: # (not True or False)
if not inclusionFiltering:
# there are no Include filters in use so 'keep' defaults to True
keep = True
else:
keep = False
if keep:
console.info('feedback> [%s]' % line)
_process = Process(None,
started=process_started,
stdout=process_feedback,
stdin=None,
stderr=process_feedback,
stopped=process_stopped)
# --->
# <status ---
local_event_Status = LocalEvent({'order': -100, 'group': 'Status', 'schema': {'type': 'object', 'properties': {
'level': {'type': 'integer'},
'message': {'type': 'string'}}}})
def isXRRunning(arg):
global questconnected
if "xrstreamingclient" in arg.stdout and questconnected == True:
global timeouts
local_event_QuestLinkStatus.emit('On')
isXRLaunched = True
timeouts = 0
if local_event_Running.getArg() == "Off":
call(lambda: lookup_local_action('LaunchApp').call(),10)
elif questconnected == True:
local_event_QuestLinkStatus.emit('Off')
global timeouts
console.log("Haven't launched Quest Link, trying again...")
local_event_Running.emit('Off')
_process.stop()
timeouts += 1
LaunchLink.call()
isXRLaunched = False
if timeouts > QUESTTIMEOUT and isXRLaunched == False:
console.error("Can't launch Quest Link! Rebooting Quest...")
timeouts = 0
quick_process([_platformTools, 'reboot'])
call(lambda: lookup_local_action('Power').call('On'), 35)
lookup_local_action('Power').call('Off')
else:
timeouts = 0
local_event_QuestLinkStatus.emit('Off')
def getBatteryLevel(arg):
if "level" in arg.stdout:
local_event_Battery.emit('%s%%' % arg.stdout[9:])
def linkCheck():
quick_process([_platformTools, 'shell "dumpsys activity activities | grep ResumedActivity"'], finished=isXRRunning)
quick_process([_platformTools, 'shell "dumpsys battery | grep level"'], finished=getBatteryLevel)
def oculusCheck():
quick_process([_platformTools, 'devices'], finished=Status_listDeviceOutput)
def statusCheck():
# recently interrupted
now = date_now()
nowMillis = now.getMillis()
errmsg = []
# check for recent interruption within the last 4 days (to incl. long weekends)
firstInterrupted = date_parse(local_event_FirstInterrupted.getArg() or '1960')
firstInterruptedDiff = nowMillis - firstInterrupted.getMillis()
lastInterrupted = date_parse(local_event_LastInterrupted.getArg() or '1960')
if local_event_DesiredPower.getArg() == "On":
if local_event_HeadsetConnectionStatus.getArg() != 'On':
global when
errmsg.append('Quest is not connected to computer, since: %s' % when)
elif local_event_QuestLinkStatus.getArg() != 'On':
errmsg.append('Quest Link is not running')
elif local_event_Running.getArg() != 'On':
errmsg.append('Application not running')
#console.error("Application not launched, check to see if the Oculus software on the computer is in a weird state!")
if errmsg:
local_event_Status.emit({'level': 2, 'message' : '%s' % errmsg})
elif firstInterruptedDiff < 4*24*3600*1000L: # (4 days)
if firstInterrupted == lastInterrupted:
timeMsgs = 'last time %s' % toBriefTime(lastInterrupted)
else:
timeMsgs = 'last time %s, first time %s' % (toBriefTime(lastInterrupted), toBriefTime(firstInterrupted))
local_event_Status.emit({'level': 1, 'message': 'Application interruptions may be taking place (%s)' % timeMsgs})
else:
local_event_Status.emit({'level': 0, 'message': 'OK'})
statusCheck_timer = Timer(statusCheck, 30)
linkCheck_timer = Timer(linkCheck, 10, stopped=True)
oculusCheck_timer = Timer(oculusCheck, 10, stopped=True)
# --->
# <--- convenience functions
# Converts into a brief time relative to now
def toBriefTime(dateTime):
now = date_now()
nowMillis = now.getMillis()
diff = (nowMillis - dateTime.getMillis()) / 60000 # in minutes
if diff == 0:
return '<1 min ago'
elif diff < 60:
return '%s mins ago' % diff
elif diff < 24*60:
return dateTime.toString('h:mm:ss a')
elif diff < 365 * 24*60:
return dateTime.toString('h:mm:ss a, E d-MMM')
elif diff > 10 * 365*24*60:
return 'never'
else:
return '>1 year'
# Decodes a typical process arg list string into an array of strings allowing for
# limited escaping or quoting or both.
#
# For example, turns:
# --name "Peter Parker" --character Spider\ Man
# into:
# ['--name', '"Peter Parker"', '--character', 'Spider Man'] (Python list)
#
def decodeArgList(argsString):
argsList = list()
escaping = False
quoting = False
currentArg = list()
for c in argsString:
if escaping:
escaping = False
if c == ' ' or c == '"': # put these away immediately (space-delimiter or quote)
currentArg.append(c)
continue
if c == '\\':
escaping = True
continue
# not escaping or dealt with special characters, can deal with any char now
if c == ' ': # delimeter?
if not quoting:
# hit the space delimeter (outside of quotes)
if len(currentArg) > 0:
argsList.append(''.join(currentArg))
del currentArg[:]
continue
if c == ' ' and len(currentArg) == 0: # don't fill up with spaces
pass
else:
currentArg.append(c)
if c == '"': # quoting?
if quoting: # close quote
quoting = False
argsList.append(''.join(currentArg))
del currentArg[:]
continue
else:
quoting = True # open quote
if len(currentArg) > 0:
argsList.append(''.join(currentArg))
return argsList
# convenience --->