|
ewemoa
|
 |
« Reply #50 on: March 02, 2009, 12:47:41 AM » |
|
The following worked a little bit better for me -- though I didn't end up seeing onBeginSearch getting invoked. What I used: - Python 2.6.x (ActiveState)
- FScript.dll version 1.13.0.0 (at least that's what I saw via the properties dialog box in explorer)
- FARR 2.48.0.1
- Windows XP
Uncommenting the last line shows that some bits seem to work for me. Ah, I also have a vague memory that czb had a Python plugin -- may be asking him might shed some light on the matter. I think a thread w/ the plugin mentioned in it says something about it being discontinued, but he still seems to have a page for it: http://czb.dcmembers.com/TodoTXT.htmlFormatted for Python with the GeSHI Syntax Highlighter [ copy or print] displayname = "TESTPython" versionstring = "0.0.1" releasedatestring = "March 2nd, 2009" author = "Author" updateurl = "" homepageurl = "" shortdescription = "TESTPython" longdescription = "Python Test Plugin, you know?" readmestring = "" iconfilename = "FScript.ico" aliasstr = "ttt" regexstr = "" regexfilterstr = "" keywordstr = "" scorestr = "300" # type UNKNOWN = 0 FILE = 1 FOLDER = 2 ALIAS = 3 URL = 4 PLUGIN = 5 CLIP = 5 # Postprocessing IMMEDIATE_DISPLAY = 0 ADDSCORE = 1 MATCH_AGAINST_SEARCH = 2 # search state constants STOPPED = 0 SEARCHING = 1 def onSearchBegin(querykey, explicit, queryraw, querynokeyword): FARR.setStrValue("DisplayAlertMessage", "woohoo") FARR.setState(querykey, SEARCHING) #start search # return result to farr (queryID, title, path, icon, entrytype=FILE, resultpostprocessing=2, score=300) FARR.emitResult(querykey, "python TITLE", "python PATH", iconfilename, ALIAS, IMMEDIATE_DISPLAY, 5000) FARR.setState(querykey, STOPPED) #stopped search # the following seems to work #FARR.setStrValue("DisplayAlertMessage", "loaded python test plugin")
|
|
|
|
« Last Edit: March 02, 2009, 12:54:09 AM by ewemoa »
|
Logged
|
|
|
|
|
|
|
ewemoa
|
 |
« Reply #52 on: March 02, 2009, 02:04:03 AM » |
|
Thanks for the info concerning 1.15  The following works for me - I haven't tested in-depth, but my suspicion about what made things work out is the signature for onSearchBegin -- I added a couple of more parameters after looking at the "Available Callbacks" section of: http://e.craft.free.fr/farr/FScript/help.htmlFormatted for Python with the GeSHI Syntax Highlighter [ copy or print] displayname = "TESTPython" versionstring = "0.0.1" releasedatestring = "March 2nd, 2009" author = "Author" updateurl = "" homepageurl = "" shortdescription = "TESTPython" longdescription = "Python Test Plugin, you know?" readmestring = "" iconfilename = "FScript.ico" aliasstr = "ttt" regexstr = "" regexfilterstr = "" keywordstr = "" scorestr = "300" # type UNKNOWN = 0 FILE = 1 FOLDER = 2 ALIAS = 3 URL = 4 PLUGIN = 5 CLIP = 5 # Postprocessing IMMEDIATE_DISPLAY = 0 ADDSCORE = 1 MATCH_AGAINST_SEARCH = 2 # search state constants STOPPED = 0 SEARCHING = 1 def onInit(currentDirectory): # FARR.setStrValue("DisplayAlertMessage", "onInit") return def onSearchBegin(querykey, explicit, queryraw, querynokeyword, modifierstring, triggermethod): # FARR.setStrValue("DisplayAlertMessage", "onSearchBegin") if not explicit: return FARR.setState(querykey, SEARCHING) #start search # return result to farr (queryID, title, path, icon, entrytype=FILE, resultpostprocessing=2, score=300) FARR.emitResult(querykey, "python TITLE", "python PATH", iconfilename, ALIAS, IMMEDIATE_DISPLAY, 5000) FARR.setState(querykey, STOPPED) #stopped search def onSetStrValue(name, value): # FARR.setStrValue("DisplayAlertMessage", "onSetStr: " + name + " " + value) return # the following seems to work #FARR.setStrValue("DisplayAlertMessage", "loaded python test plugin")
|
|
|
|
|
Logged
|
|
|
|
|
|
ChrisVN
|
 |
« Reply #53 on: March 02, 2009, 02:46:21 AM » |
|
Thanks for the tips so far.
I will try the newest version of FScript and I will also try to get TodoTXT running. I don't like the idea of downgrading to Python v2.x - but if we are running out of ideas I will also test this one.
Any other suggestions? chris
|
|
|
|
|
Logged
|
|
|
|
|
ChrisVN
|
 |
« Reply #54 on: March 02, 2009, 02:57:39 AM » |
|
Thanks again
Tonight I will try out the suggested signature for onSearchBegin: def onSearchBegin(querykey, explicit, queryraw, querynokeyword, modifierstring, triggermethod):
chris
|
|
|
|
|
Logged
|
|
|
|
|
ewemoa
|
 |
« Reply #55 on: March 02, 2009, 03:24:08 AM » |
|
I tried uninstalling Python 2.6.x and installing Python 3.x -- didn't seem to work here [1], but may be other people will experience differently. There's a bit at: http://activestate.com/activepython/python3/ that says: Many 3rd-party modules and extensions that you may depend upon may not yet be available for Python 3. [Currently this includes the Python for Windows (pywin32) extensions that are a default part of ActivePython on Windows.] As a result you may want to continue to use Python 2 for the time being. However, you can safely install both ActivePython 2.6 and ActivePython 3.0 side-by-side on your computer so that you can experiment with Python 3 while still using Python 2 for your current code. Python 3.0 is Python's future, however the Python 2.x line will continue to see new releases for some time to allow for a long and smooth transition. ActivePython 2.6 is the latest ActivePython 2.x release.
Perhaps the part in bold-face is related... Ah, I didn't mention this earlier, but my sense of the corrupt text was that this happens if some of certain variables (e.g. releasedatestring) are not defined. [1] I didn't even notice the plugin appearing...
|
|
|
|
|
Logged
|
|
|
|
|
ChrisVN
|
 |
« Reply #56 on: March 02, 2009, 03:40:05 AM » |
|
[1] I didn't even notice the plugin appearing... This is exactly what happend to me at first. (I don't know what has changed that the plugin finally showed up) -> Seems like I will have to work with Python v2.6 But I will also try this at first: Ah, I didn't mention this earlier, but my sense of the corrupt text was that this happens if some of certain variables (e.g. releasedatestring) are not defined.
|
|
|
|
|
Logged
|
|
|
|
|
ChrisVN
|
 |
« Reply #57 on: March 02, 2009, 02:19:48 PM » |
|
Special thanks to ewemoa - 2 of your tips did the trick  Trick #1: Python v3 is NOT working After installing Python 2.6 the plug-in showed up in the list Trick #2: Python requires the whole signature for onSearchBegin Even though the java script samples don't use the whole signature, python seems to need all parameters including "modifierstring" and "triggermethod" A big 'thank you' for the useful tips now I can go on and experience the new possibilities.
|
|
|
|
|
Logged
|
|
|
|
|
ewemoa
|
 |
« Reply #58 on: March 02, 2009, 06:28:40 PM » |
|
Great to hear it's working 
|
|
|
|
|
Logged
|
|
|
|
|
ecaradec
|
 |
« Reply #59 on: March 04, 2009, 05:39:37 AM » |
|
ChrisVN : Thank you for sharing your findings. 
|
|
|
|
|
Logged
|
|
|
|
|
ewemoa
|
 |
« Reply #60 on: March 14, 2009, 08:23:46 AM » |
|
A side note -- I compared checksums of the FScript.dll (1.15) mentioned in this thread: http://e.craft.free.fr/farr/FScript/ SHA-1: 5f71f21959139002bb022d0c7ae9d0f1edc83ca6 to that of the one (also comes up as 1.15?) included in CZBFSubScript.zip in the following thread: http://www.donationcoder....m/index.php?topic=16942.0 SHA-1: 96bba6cb3480025bc7e357cc143eec2c0b4f7605 I suspected the files were different after failing to get the socket stuff to work with the former one.
|
|
|
|
|
Logged
|
|
|
|
|
ecaradec
|
 |
« Reply #61 on: March 14, 2009, 10:53:39 AM » |
|
I have probably done several build of the 1.15 version. However (if I didn't screw up ), they should be equivalent. Visual Studio probably add informations specific to the time of the build, or something like that, causing sha1 to be different.
|
|
|
|
|
Logged
|
|
|
|
|
ewemoa
|
 |
« Reply #62 on: March 14, 2009, 05:43:10 PM » |
|
Thanks for the clarification.
I think it is worth noting that at least one of them (the former one mentioned in my earlier post) doesn't appear to support the FARR.newTCPSocket(). If you don't mind, perhaps you could update that one or confirm whether it supports FARR.newTCPSocket().
|
|
|
|
|
Logged
|
|
|
|
|
ecaradec
|
 |
« Reply #63 on: March 15, 2009, 03:38:21 PM » |
|
Hum, there is probably two 1.15 version, which is not very cool. I'm making an automated build for future version, so that this kind of issues would not occur anymore. You are probably safe to use the 1.15 version with socket support. As I remember, it should be the only difference between the two versions. Thank you for reporting the issue.
|
|
|
|
|
Logged
|
|
|
|
|
ewemoa
|
 |
« Reply #64 on: March 15, 2009, 04:08:57 PM » |
|
Thanks for the clarification -- I am happy to be using the version with socket support (and it is nice to hear from the creator that that's probably ok  ).
|
|
|
|
|
Logged
|
|
|
|
|
ewemoa
|
 |
« Reply #65 on: March 19, 2009, 09:05:58 PM » |
|
I am starting to experiment more with writing plugins using Python. My experience so far is that I do not know how to become aware of at least one type of runtime difficulty. Specifically, I do not know that the plugin has aborted execution due to an exception being raised. Tracking down relevant lines in the source code can become a chore with no hints! Does any one have any ideas (other than wrap every function call body in try/except) about how to be alerted about runtime exceptions? Any chance that FScript could make a stacktrace available (or may be it does already and I don't know where to look)? For comparison, when this type of thing occurs for a JavaScript plugin, I am alerted by my local installation of MS Script Debugger...I went looking for something similar for Python, but so far I have not been successful in locating anything. I hope someone has some good ideas regarding this situation Edit: catch -> except ... oops 
|
|
|
|
« Last Edit: March 20, 2009, 12:58:46 AM by ewemoa »
|
Logged
|
|
|
|
|
ewemoa
|
 |
« Reply #66 on: March 21, 2009, 12:56:00 AM » |
|
At the moment, I'm taking the wrap function bodies approach -- as an example, an onInit might look like: Formatted for Python with the GeSHI Syntax Highlighter [ copy or print] def onInit(currentDirectory): try: # XXX 1 / 0 except: type, value, tb = sys.exc_info() FARR.setStrValue("DisplayAlertMessage", repr(traceback.format_exception(type, value, tb)))
This is assuming something like the following also in an appropriate location in the code: Formatted for Python with the GeSHI Syntax Highlighter [ copy or print] import sys, traceback
DisplayAlertMessage is a bit tight on space, so I'm considering alternatives. Perhaps bring up some browser window? It'd be neat to display the stack trace, but also perhaps load the source for the file with the problem and highlight the problematic line. Mmm, how to do that... Doing this for each function sounds painful so I'm thinking of writing some code to appropriately "instrument" certain functions -- may be just the plugin entry points. This code could then be placed so that it runs when the plugin is first loaded. Any reflections?
|
|
|
|
|
Logged
|
|
|
|
|
ewemoa
|
 |
« Reply #67 on: March 21, 2009, 05:18:22 AM » |
|
I've made something using Python's decorators. I have the following code near the beginning of a plugin: Formatted for Python with the GeSHI Syntax Highlighter [ copy or print] import sys, traceback, pprint # "advice" -- quick-and-dirty wrapping/instrumenting code # # to use, place @around before a function definition line. # for example, for a function f: # # @around # def f(arg1): # print arg1 # # based on code at: # http://livingcode.org/2009/aspect-oriented-python def around(fn): def wrapped(*args, **kws): try: return fn(*args, **kws) except: import pprint xtype, value, tb = sys.exc_info() trace = traceback.format_exception(xtype, value, tb) tracestr = pprint.pformat(trace) efname = plugindir() + "\\exception.txt" f = open(efname, "w") f.write(tracestr) f.close() FARR.setStrValue("launch", "notepad.exe " + efname) return wrapped
Then example usage for onInit might be: Formatted for Python with the GeSHI Syntax Highlighter [ copy or print] @around def onInit(currentDirectory): FARR.setStrValue("DisplayAlertMessage", "Know any perfect numbers?") # XXX 1 / 0
That is, just place "@around" on the line preceding the first line of a function definition -- assuming you want the function in question "wrapped". The basic idea seems ok -- but using "launch" w/ "showhtml" isn't working out so well for plugin reloads. Looks like FARR quickly goes on to display the result of the plugins reloading so I don't get enough time to read the stack trace...Edit: It's a bit ugly, but now the code writes exception information to a temporary file within the plugin directory and opens it using notepad.
|
|
|
|
« Last Edit: March 22, 2009, 06:29:23 AM by ewemoa »
|
Logged
|
|
|
|
|
mouser
|
 |
« Reply #68 on: December 25, 2009, 11:06:28 PM » |
|
Do we have a python and ruby example somewhere?
|
|
|
|
|
Logged
|
|
|
|
|
ecaradec
|
 |
« Reply #69 on: December 26, 2009, 09:49:36 AM » |
|
Yep, debugging in python or ruby suck. the activescript binding of python and ruby is limited to running script but not debugging them, and the debugging support is required to get correct error lines, etc... May be there is somewhere a debuggable active script implementation of python ? Once you have a good understanding on what FARR pass as parameters and order of methods call, you can try running plugins standalone and integrate them as FARR plugin at the end. Not the solution I'd like but it helps.
|
|
|
|
|
Logged
|
|
|
|
|
relipse
|
 |
« Reply #70 on: April 09, 2013, 10:50:06 PM » |
|
Can someone help me write a plugin? I don't understand any of the example plugins.
I want to write a plugin that lets you automatically search google when you press a hotkey (for example alt+g) with whatever text is being shown.
I also want to write a plugin that lets me find a particular window that is open since i always have about 20-25 For example you open FARR type w <window name> and it will jump to that open window (faster than alt-tab if you know what you are looking for)
Jim
|
|
|
|
|
Logged
|
|
|
|
|
mouser
|
 |
« Reply #71 on: April 12, 2013, 10:32:24 AM » |
|
Jim, The Fprocs plugin should solve your second request -- there is also an alt-tab like plugin somewhere but i can't find it. As for a plugin that automatically searches google when you press a hotkey -- that's an interesting idea.. i can think of a couple of ways that could ALMOST be done without using a plugin.. Perhaps it would be useful if i added some more options to the hotkey configuration in FARR to support NON-GLOBAL local hotkeys..
|
|
|
|
|
Logged
|
|
|
|
|