Skip to content

Commit

Permalink
fixes #134, async/consume
Browse files Browse the repository at this point in the history
  • Loading branch information
synkarius committed Feb 1, 2016
1 parent 587c6fa commit 17af08b
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion caster/asynch/_hmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def settings_window(nexus):
if not utilities.window_exists(None, settings.STATUS_WINDOW_TITLE + settings.SOFTWARE_VERSION_NUMBER):
h_launch.launch(settings.WXTYPE_SETTINGS)
on_complete = AsynchronousAction.hmc_complete(lambda data: receive_settings(data), nexus)
AsynchronousAction([L(S(["cancel"], on_complete, None))], time_in_seconds=1, repetitions=300, blocking=False).execute()
AsynchronousAction([L(S(["cancel"], on_complete))], time_in_seconds=1, repetitions=300, blocking=False).execute()

class LaunchRule(MappingRule):
mapping = {
Expand Down
8 changes: 1 addition & 7 deletions caster/lib/ccr/core/nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class NavigationNon(MappingRule):
mapping = {
"<direction> <time_in_seconds>": AsynchronousAction([L(S(["cancel"], Key("%(direction)s")))],
"<direction> <time_in_seconds>": AsynchronousAction([L(S(["cancel"], Key("%(direction)s"), consume=False))],
repetitions=1000, blocking=False ),
"erase multi clipboard": R(Function(navigation.erase_multi_clipboard, nexus=_NEXUS),
rdescript="Erase Multi Clipboard"),
Expand Down Expand Up @@ -118,12 +118,6 @@ class Navigation(MergeRule):
lambda fnparams: UntilCancelled(Mimic(*filter(lambda s: s != "periodic", fnparams)), 1).execute(), \
use_spoken=True))]),
# VoiceCoder-inspired -- these should be done at the IDE level
# "jump in": AsynchronousAction([L(S(["cancel"], context.nav, ["right", "(~[~{~<"]))
# ], time_in_seconds=0.1, repetitions=50, rdescript="Jump: In" ),
# "jump out": AsynchronousAction([L(S(["cancel"], context.nav, ["right", ")~]~}~>"]))
# ], time_in_seconds=0.1, repetitions=50, rdescript="Jump: Out" ),
# "jump back": AsynchronousAction([L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))
# ], time_in_seconds=0.1, repetitions=50, rdescript="Jump: Back" ),
"fill <target>": R(Key("escape, escape, end"), show=False) +
AsynchronousAction([L(S(["cancel"], Function(context.fill_within_line, nexus=_NEXUS)))
], time_in_seconds=0.2, repetitions=50, rdescript="Fill" ),
Expand Down
2 changes: 1 addition & 1 deletion caster/lib/ccr/recording/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def chain_alias(self):
if text is not None:
h_launch.launch(settings.QTYPE_INSTRUCTIONS, data="Enter_spec_for_command|")
on_complete = AsynchronousAction.hmc_complete(lambda data: self.refresh(data[0].replace("\n", ""), text), self.nexus)
AsynchronousAction([L(S(["cancel"], on_complete, None))],
AsynchronousAction([L(S(["cancel"], on_complete))],
time_in_seconds=0.5,
repetitions=300,
blocking=False).execute()
Expand Down
2 changes: 1 addition & 1 deletion caster/lib/ccr/recording/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def record_from_history(self):
# use a response window to get a spec and word sequences for the new macro
h_launch.launch(settings.QTYPE_RECORDING, data=formatted)
on_complete = AsynchronousAction.hmc_complete(lambda data: self.add_recorded_macro(data), self.nexus)
AsynchronousAction([L(S(["cancel"], on_complete, None))],
AsynchronousAction([L(S(["cancel"], on_complete))],
time_in_seconds=0.5,
repetitions=300,
blocking=False).execute()
Expand Down
5 changes: 4 additions & 1 deletion caster/lib/dev/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def experiment():
# comm = Communicator()
# comm.get_com("status").error(0)

def run_remote_debugger():
utilities.remote_debug("dev.py")


COUNT=5
Expand Down Expand Up @@ -118,7 +120,8 @@ class DevelopmentHelp(MappingRule):
"refresh debug file": Function(devgen.refresh),
"Agrippa <filetype> <path>": Function(grep_this),
"run rule complexity test": Function(lambda: run_tests()),
"run unit tests": Function(testrunner.run_tests)
"run unit tests": Function(testrunner.run_tests),
"run remote debugger": Function(run_remote_debugger),
}
extras = [
Dictation("text"),
Expand Down
2 changes: 2 additions & 0 deletions caster/lib/dfplus/state/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class AsynchronousAction(ContextSeeker):
'''
def __init__(self, forward, time_in_seconds=1, repetitions=0,
rdescript="unnamed command (A)", blocking=True, finisher=None):
forward[0].sets[0].consume = False # consume is for ContextSeekers, not AsynchronousActions
ContextSeeker.__init__(self, None, forward)
self.repetitions = repetitions
self.time_in_seconds = time_in_seconds
Expand All @@ -60,6 +61,7 @@ def __init__(self, forward, time_in_seconds=1, repetitions=0,
self.base = finisher
assert self.forward is not None, "Cannot create AsynchronousAction with no termination commands"
assert len(self.forward) == 1, "Cannot create AsynchronousAction with > or < one purpose"

def _execute(self, data=None):
if data is not None:
if "time_in_seconds" in data: self.time_in_seconds=float(data["time_in_seconds"])
Expand Down
8 changes: 4 additions & 4 deletions caster/lib/dfplus/state/actions2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def check_for_response():
return True

AsynchronousAction.__init__(self, # cannot block, if it does, it'll block its own confirm command
[L(S(["cancel"], check_for_response, None))],
1, repetitions, rdescript, False)
[L(S(["cancel"], check_for_response))],
1, repetitions, rdescript, blocking=False)
self.rspec = rspec
self.box_type = box_type
self.box_settings = box_settings # custom instructions for setting up the tk window ("Homunculus")
Expand Down Expand Up @@ -83,7 +83,7 @@ def __init__(self, base, rspec="default", rdescript="unnamed command (CA)", inst
self.set_nexus(nexus)
on_complete = AsynchronousAction.hmc_complete(lambda data: receive_response(data), self.nexus())
AsynchronousAction.__init__(self,
[L(S(["cancel"], on_complete, None))],
[L(S(["cancel"], on_complete))],
1, 60, rdescript, False)# cannot block, if it does, it'll block its own confirm command

self.base = base
Expand Down Expand Up @@ -243,5 +243,5 @@ def attempt_focus():

class UntilCancelled(AsynchronousAction):
def __init__(self, action, t=3):
AsynchronousAction.__init__(self, [L(S(["cancel"], action, consume=False))], t, 100, "UC", False, None)
AsynchronousAction.__init__(self, [L(S(["cancel"], action))], t, 100, "UC", False, None)
self.show = True
2 changes: 1 addition & 1 deletion caster/lib/pita/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
def scan_directory(nexus):
on_complete = AsynchronousAction.hmc_complete(lambda data: _scan_directory(data, nexus), nexus)
h_launch.launch(settings.QTYPE_DIRECTORY)
AsynchronousAction([L(S(["cancel"], on_complete, None))],
AsynchronousAction([L(S(["cancel"], on_complete))],
time_in_seconds=0.5,
repetitions=300,
blocking=False).execute()
Expand Down

0 comments on commit 17af08b

Please sign in to comment.