Skip to content

Commit

Permalink
sikuli fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
synkarius committed Jun 12, 2015
1 parent 08654fb commit c3230bf
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 5 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ bin/misc
*.json
*.bak
*.class
*.sikuli
test.py
*.tmp
unins000.*
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions caster/asynch/sikuli/scripts/example.sikuli/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

<html>
<head>
<style type="text/css">
.sikuli-code {
font-size: 20px;
font-family: "Osaka-mono", Monospace;
line-height: 1.5em;
display:table-cell;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
width: 99%; /* remove horizontal scroll-bar when viewing in IE7 */
}
.sikuli-code img {
vertical-align: middle;
margin: 2px;
border: 1px solid #ccc;
padding: 2px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-moz-box-shadow: 1px 1px 1px gray;
-webkit-box-shadow: 1px 1px 2px gray;
}
.kw {
color: blue;
}
.skw {
color: rgb(63, 127, 127);
}

.str {
color: rgb(128, 0, 0);
}

.dig {
color: rgb(128, 64, 0);
}

.cmt {
color: rgb(200, 0, 200);
}

h2 {
display: inline;
font-weight: normal;
}

.info {
border-bottom: 1px solid #ddd;
padding-bottom: 5px;
margin-bottom: 20px;
display: none;
}

a {
color: #9D2900;
}

body {
font-family: "Trebuchet MS", Arial, Sans-Serif;
}

</style>
</head>
<body>
<div class="info">
<h2>example.sikuli\example.sikuli</h2> <a href="example.sikuli\example.zip">(Download this script)</a>
</div>
<pre class="sikuli-code">
<span class="kw">from</span> sikuli <span class="kw">import</span> *

<span class="kw">def</span> export_command():
<span class="skw">click</span>(<img src="1434072940616.png" />)
</pre>
</body>
</html>
4 changes: 4 additions & 0 deletions caster/asynch/sikuli/scripts/example.sikuli/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from sikuli import *

def export_command():
click("1434072940616.png")
131 changes: 131 additions & 0 deletions caster/asynch/sikuli/scripts/xmlrpc_server.sikuli/xmlrpc_server.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@

<html>
<head>
<style type="text/css">
.sikuli-code {
font-size: 20px;
font-family: "Osaka-mono", Monospace;
line-height: 1.5em;
display:table-cell;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
width: 99%; /* remove horizontal scroll-bar when viewing in IE7 */
}
.sikuli-code img {
vertical-align: middle;
margin: 2px;
border: 1px solid #ccc;
padding: 2px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-moz-box-shadow: 1px 1px 1px gray;
-webkit-box-shadow: 1px 1px 2px gray;
}
.kw {
color: blue;
}
.skw {
color: rgb(63, 127, 127);
}

.str {
color: rgb(128, 0, 0);
}

.dig {
color: rgb(128, 64, 0);
}

.cmt {
color: rgb(200, 0, 200);
}

h2 {
display: inline;
font-weight: normal;
}

.info {
border-bottom: 1px solid #ddd;
padding-bottom: 5px;
margin-bottom: 20px;
display: none;
}

a {
color: #9D2900;
}

body {
font-family: "Trebuchet MS", Arial, Sans-Serif;
}

</style>
</head>
<body>
<div class="info">
<h2>xmlrpc_server.sikuli\xmlrpc_server.sikuli</h2> <a href="xmlrpc_server.sikuli\xmlrpc_server.zip">(Download this script)</a>
</div>
<pre class="sikuli-code">
<span class="kw">import</span> SimpleXMLRPCServer
<span class="kw">from</span> SimpleXMLRPCServer <span class="kw">import</span> *
<span class="kw">import</span> sys
<span class="kw">from</span> inspect <span class="kw">import</span> getmembers, isfunction

SCRIPTS_PATH = sys.argv[<span class="dig">0</span>].split(<span class="str">"\\xmlrpc_server.sikuli"</span>)[<span class="dig">0</span>]
BASE_PATH = sys.argv[<span class="dig">0</span>].split(<span class="str">"MacroSystem"</span>)[<span class="dig">0</span>] + <span class="str">"MacroSystem"</span>

modules = []
server = SimpleXMLRPCServer((<span class="str">"127.0.0.1"</span>, <span class="dig">8000</span>), allow_none=True)
quit = <span class="dig">0</span>

<span class="kw">def</span> ping():
<span class="kw">return</span> <span class="dig">1</span>
<span class="kw">def</span> list_functions():
<span class="kw">global</span> modules
<span class="kw">return</span> modules
<span class="kw">def</span> terminate():
<span class="kw">global</span> quit
quit = <span class="dig">1</span>
<span class="kw">return</span> <span class="dig">1</span>

server.register_function(list_functions, <span class="str">"list_functions"</span>)
server.register_function(terminate, <span class="str">"terminate"</span>)

<span class="kw">if</span> SCRIPTS_PATH <span class="kw">not</span> <span class="kw">in</span> sys.path:
sys.path.append(SCRIPTS_PATH)
<span class="kw">for</span> s <span class="kw">in</span> [x[<span class="dig">0</span>] <span class="kw">for</span> x <span class="kw">in</span> os.walk(SCRIPTS_PATH)]:
<span class="kw">if</span> s.endswith(<span class="str">".sikuli"</span>) <span class="kw">and</span> <span class="kw">not</span> s.endswith(<span class="str">"xmlrpc_server.sikuli"</span>):
mdl_name = s.split(<span class="str">"."</span>)[<span class="dig">0</span>].split(<span class="str">"\\"</span>)[-<span class="dig">1</span>]
<span class="kw">exec</span>(<span class="str">"import "</span> + mdl_name)
<span class="kw">exec</span>(<span class="str">"l = getmembers("</span> + mdl_name+<span class="str">", isfunction)"</span>)
<span class="kw">for</span> d <span class="kw">in</span> l:
<span class="kw">if</span> d[<span class="dig">0</span>].startswith(<span class="str">"export_"</span>):
registered_function_name=mdl_name+<span class="str">"_"</span>+d[<span class="dig">0</span>].replace(<span class="str">"export_"</span>, <span class="str">""</span>)
modules.append(registered_function_name)
<span class="kw">exec</span>(<span class="str">"server.register_function("</span>+mdl_name+<span class="str">"."</span>+d[<span class="dig">0</span>]+<span class="str">", '"</span>+registered_function_name+<span class="str">"')"</span>)


<span class="kw">print</span> <span class="str">"Caster Sikuli Bridge\n\nlist of available commands "</span> + str(modules)



<span class="cmt"># examples
</span><span class="kw">def</span> add(self, x, y):
<span class="kw">return</span> x + y




<span class="kw">try</span>:
<span class="kw">while</span> <span class="kw">not</span> quit:
server.handle_request()
<span class="cmt"># server.serve_forever()
</span><span class="kw">except</span> KeyboardInterrupt:
<span class="kw">print</span> <span class="str">'Exiting'</span>
</pre>
</body>
</html>
55 changes: 55 additions & 0 deletions caster/asynch/sikuli/scripts/xmlrpc_server.sikuli/xmlrpc_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import SimpleXMLRPCServer
from SimpleXMLRPCServer import *
import sys
from inspect import getmembers, isfunction

SCRIPTS_PATH = sys.argv[0].split("\\xmlrpc_server.sikuli")[0]
BASE_PATH = sys.argv[0].split("MacroSystem")[0] + "MacroSystem"

modules = []
server = SimpleXMLRPCServer(("127.0.0.1", 8000), allow_none=True)
quit = 0

def ping():
return 1
def list_functions():
global modules
return modules
def terminate():
global quit
quit = 1
return 1

server.register_function(list_functions, "list_functions")
server.register_function(terminate, "terminate")

if SCRIPTS_PATH not in sys.path:
sys.path.append(SCRIPTS_PATH)
for s in [x[0] for x in os.walk(SCRIPTS_PATH)]:
if s.endswith(".sikuli") and not s.endswith("xmlrpc_server.sikuli"):
mdl_name = s.split(".")[0].split("\\")[-1]
exec("import " + mdl_name)
exec("l = getmembers(" + mdl_name+", isfunction)")
for d in l:
if d[0].startswith("export_"):
registered_function_name=mdl_name+"_"+d[0].replace("export_", "")
modules.append(registered_function_name)
exec("server.register_function("+mdl_name+"."+d[0]+", '"+registered_function_name+"')")


print "Caster Sikuli Bridge\n\nlist of available commands " + str(modules)



# examples
def add(self, x, y):
return x + y




try:
while not quit:
server.handle_request()
except KeyboardInterrupt:
print 'Exiting'
10 changes: 7 additions & 3 deletions caster/asynch/sikuli/sikuli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ def generate_commands(list_of_functions):
spec = " ".join(fname.split("_"))
mapping[spec] = Function(execute, fname=fname)
grammar.unload()
grammar.add_rule(MappingRule(mapping=mapping))
grammar = Grammar("sikuli")
grammar.add_rule(MappingRule(mapping=mapping, name="sikuli server"))
grammar.load()

def start_server_proxy():
global server_proxy
server_proxy = control.COMM.get_com("sikuli")
generate_commands(server_proxy.list_functions())
fns = server_proxy.list_functions()
if len(fns)>0:
generate_commands(fns)
utilities.report("Caster-Sikuli server started successfully.")

def server_proxy_timer_fn():
Expand All @@ -51,6 +54,7 @@ def server_proxy_timer_fn():
control.TIMER_MANAGER.remove_callback(server_proxy_timer_fn)
except Exception:
pass
# utilities.simple_log(False)

def unload():
global grammar
Expand All @@ -61,7 +65,7 @@ def refresh():
''' should be able to add new scripts on the fly and then call this '''
unload()
global grammar
grammar = Grammar("sikuli")
grammar = Grammar("si/kuli")
def refresh_sick_command():
server_proxy.terminate()
refresh()
Expand Down
2 changes: 1 addition & 1 deletion caster/lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
INISETPATH = 'C:/NatLink/NatLink/MacroSystem/caster/bin/data/settings.json'

# title
SOFTWARE_VERSION_NUMBER = "0.4.6.1"
SOFTWARE_VERSION_NUMBER = "0.4.6.2"
SOFTWARE_NAME = "Caster v " + SOFTWARE_VERSION_NUMBER
S_LIST_VERSION = "Sticky List v " + SOFTWARE_VERSION_NUMBER
DISPEL_VERSION = "Dispel v " + SOFTWARE_VERSION_NUMBER
Expand Down

0 comments on commit c3230bf

Please sign in to comment.