Skip to content

Commit 9b89120

Browse files
committed
checking in python version of the code
1 parent 3ab56d3 commit 9b89120

8 files changed

Lines changed: 441 additions & 0 deletions

File tree

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@
22
main/Utility/Properties/Resources.resources
33

44
main/Testing/Properties/.DS_Store
5+
6+
python/.DS_Store
7+
8+
python/.svn/all-wcprops
9+
10+
python/.svn/entries
11+
12+
*.svn-base

python/Automation.tracetemplate

3.87 KB
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repeat
2+
set procs to ""
3+
tell application "System Events"
4+
set procs to name of every process
5+
end tell
6+
if procs contains "SecurityAgent" then
7+
tell application "System Events"
8+
tell process "SecurityAgent" to set value of text field 1 of scroll area 1 of group 1 of window 1 to "$USERNAME"
9+
tell process "SecurityAgent" to set value of text field 2 of scroll area 1 of group 1 of window 1 to "$PASSWORD"
10+
click button 2 of group 2 of window 1 of application process "SecurityAgent"
11+
log ("Dismissed Security Dialog")
12+
end tell
13+
end if
14+
delay 1
15+
end repeat

python/bootstrap.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* ***** helper functions ***** */
2+
3+
// delay in seconds
4+
function delay(secs)
5+
{
6+
var date = new Date();
7+
var curDate = null;
8+
9+
do { curDate = new Date(); }
10+
while(curDate-date < (secs * 1000.0));
11+
}
12+
13+
// find cell with name
14+
function findCellWithName(cellName, window) {
15+
16+
return window.visibleCells()[cellName];
17+
18+
for (index = 0; index < window.tableViews().length; index = index + 1) {
19+
cell = window.tableViews()[index].visibleCells()[cellName];
20+
if ((cell != null) && (cell.toString() != "[object UIAElementNil]")) {
21+
return cell;
22+
}
23+
}
24+
return UIAElementNil;
25+
}
26+
27+
/* ***** main loop ***** */
28+
29+
// automation globals
30+
var iosAutoPath = "$PATH_ROOT"
31+
var target = UIATarget.localTarget();
32+
var application = target.frontMostApp();
33+
var host = target.host();
34+
var mainWindow = application.mainWindow();
35+
36+
// loop variables
37+
var runLoop = true;
38+
var instructionNumber = 0;
39+
40+
// main loop
41+
while (runLoop)
42+
{
43+
var instructionFile = iosAutoPath + instructionNumber.toString() + "-cmd.txt";
44+
var responseFile = iosAutoPath + instructionNumber.toString() + "-resp.txt";
45+
var instruction = host.performTaskWithPathArgumentsTimeout("/bin/cat", [instructionFile], 5);
46+
if (instruction.exitCode == 0)
47+
{
48+
var resp = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<collection>\n";
49+
var instructionText = instruction.stdout;
50+
try
51+
{
52+
var jsCommands = instructionText.split('\n');
53+
for (var jsCommandIndex = 0; jsCommandIndex < jsCommands.length; jsCommandIndex++)
54+
{
55+
var jsCommand = jsCommands[jsCommandIndex];
56+
try
57+
{
58+
UIALogger.logDebug(instructionNumber.toString() + "." + jsCommandIndex.toString() + " - Command - " + jsCommand);
59+
var evalResult = eval(jsCommand);
60+
if (evalResult == null)
61+
{
62+
evalResult = "";
63+
}
64+
UIALogger.logDebug(instructionNumber.toString() + "." + jsCommandIndex.toString() + " - Response - " + evalResult.toString());
65+
resp = resp + "<response>" + "0," + evalResult.toString() + "</response>\n";
66+
}
67+
catch (err)
68+
{
69+
UIALogger.logWarning("js command execution failed: " + err.description);
70+
resp = resp + "<response>" + "-1," + err.description + "</response>\n";
71+
}
72+
}
73+
}
74+
catch (err)
75+
{
76+
UIALogger.logWarning("could not parse intruction set: " + err.description);
77+
resp = resp + "<error>could not parse intruction set</error>\n";
78+
}
79+
resp = resp + "</collection>\n";
80+
UIALogger.logDebug("INSTRUCTION SET #" + instructionNumber.toString() + " XML RESPONSE:\n\n" + resp + "\n");
81+
host.performTaskWithPathArgumentsTimeout("/usr/bin/python", [ iosAutoPath + "writeResponse.py" ,responseFile, resp], 5);
82+
UIALogger.logDebug("END INSTRUCTION SET #" + instructionNumber.toString());
83+
instructionNumber++;
84+
UIALogger.logDebug("BEGIN INSTRUCTION SET #" + instructionNumber.toString());
85+
}
86+
}

0 commit comments

Comments
 (0)