SCRIPTS
Any arbitrary system command qualifies as a 'script' which jumpy will execute and listen for
API calls while it's running. Generally your script does its thing, maybe adds
some items to the xmb and exits. If your needs are simple and/or you prefer reading code, skip to Quick Start or
Examples, otherwise here are a few basics:
- A script is always run in its own directory.
- A script doesn't necessarily need to interact with the API.
- Python scripts found inside 'plugins/jumpy' are called automatically at startup with no arguments. You can only add folders during this first call.
- Other scripts can be located anywhere, and are registered with Jumpy by means of jumpy-scripts.ini. They can be called at startup, shutdown, or placed on the xmb for future use.
- Any folder item added with addItem will execute whatever command
you've specified in the
cmd
parameter when the user clicks on it in the future. Usually you will want your future command to call the same script but with different arguments. - Commands with '
&
' as the last argument will be launched asynchronously. - Any media item you add will be passed along to PMS for normal processing.
- Python scripts communicate with Jumpy via internal API calls to the jumpy python module.
- Other scripts communicate with Jumpy by using an equivalent command-line syntax to make API calls on the system.
- The script's runtime environment is set such that PMS' standard binary tools
ffmpeg mplayer vlc mencoder tsmuxer flac
eac3to dcraw and convert (imagemagick)
Quick Start
- If all you need is to run some arbitrary command, create a section in jumpy-scripts.ini
(located wherever PMS.conf is) modeled on these:
; Create the folder "Jumpy > my scripts > testing > hello" on the xmb ; containing an action labeled 'click me' which will run the command ; 'echo hello' when the user clicks on it. [my scripts/testing/hello] cmd = pms addCmd "click me" "echo hello" ; Run the command 'echo "foo"' at startup ; (note the '+' which means 'execute at startup'). [+foo] cmd = echo "foo" ; Run the command 'echo "bar"' at shutdown ; (note the '-' which means 'execute at shutdown'). [-bar] cmd = echo "bar"and restart PMS. Any output from your command will appear in jumpy.log.
Quick Start - Players
- A player can be as simple as a single command. Here's one to
play your mpegs and vobs upside-down, defined as a one-liner in jumpy-scripts.ini:
[+flipflop]
cmd = pms addPlayer flipflop "ffmpeg -y -i '${filename}' -vf 'vflip,hflip' -target ntsc-dvd ${outfile}" "f:mpg|vob m:video/mpeg"
If you want to try it out add it to jumpy-scripts.ini, restart and look for flipflop items in
the #--TRANSCODE--# folder, since mpegs are likely streamed as-is by default.
For details see
pms.addPlayer
, and
Players.
API
-
The python API is initialized on import
import jumpydefining a global object pms (i.e. the current xmb folder) with the following methods:
(name, cmd, thumb=None)
pms.addBookmark
(name, cmd, thumb=None)
pms.addAudio
(name, cmd, thumb=None, details=None)
pms.addImage
(name, cmd, thumb=None, details=None)
pms.addVideo
(name, cmd, thumb=None, details=None)
pms.addPlaylist
(name, cmd, thumb=None)
pms.addISO
(name, cmd, thumb=None)
pms.addAudiofeed
(name, cmd, thumb=None)
pms.addImagefeed
(name, cmd, thumb=None)
pms.addVideofeed
(name, cmd, thumb=None)
- Convenience functions for
pms.addItem
with the appropriate
type
built-in.(type, name, cmd, thumb=None, details=None)
or
pms.addItem
(type, name, [cmd, argv1, argv2, ...], thumb=None, details=None)
where
type
is one of these constants:# media items # dynamic items PMS_AUDIO PMS_FOLDER PMS_IMAGE PMS_BOOKMARK PMS_VIDEO PMS_ACTION PMS_UNKNOWN PMS_PLAYLIST # hybrid items PMS_ISO PMS_MEDIA PMS_AUDIOFEED PMS_UNRESOLVED PMS_IMAGEFEED PMS_VIDEOFEED
name
is the item's label.- Using a unix-style path as the label (e.g. '
myscripts/perl/foo
') will create the specified path on the xmb, branching from the current folder if relative or the xmb root if absolute. Also:- '
~
' is the Jumpy folder. - If there's any chance your label may contain a literal '
/
' use pms.esc to escape it:pms.addVideo(pms.esc('Part 1/2'), 'part1.mpg')
- '
- Using a unix-style path as the label (e.g. '
cmd
is either a command or a uri depending on the giventype
:- For dynamic items
cmd
is the command to be executed in the future when the user opens the folder on the xmb. It can be either:- a typical command string to be parsed according to the usual system rules.
- a python list of strings, i.e. a command array.
- a special delimited string
describing a flattened command array using the following array notation syntax:
"[command , arg1 , arg2 , arg3 , arg4 ... ]"
- enclose your array in square
[]
brackets. - delimit your args using a comma with a space on both sides, i.e. '
,
'.
"[echo , hello world]"
. This form avoids embedded quotes when your args contain spaces, and is useful for other languages making system calls to the API. - enclose your array in square
- For dynamic items
- For media items
cmd
is a single resolved media path/url to be passed along to PMS for normal processing. - For hybrid items
cmd
can be either a path/url or a command, depending on how you use it. - as a command it can include the runtime variable
${home}
which expands to the jumpy home folder.
thumb
is the item's thumbnail image, and can be either
- a path or url to to an image file.
- or the name of a pre-defined icon.
details
is a python dict describing the item's detailed properties
with any of the following keys:
media
: a dict of media properties with any of these keys:duration
: a time string in seconds or hh:mm:ss format.size
: the total number of bytes.streams
: a list of dicts each describing one stream and containing the mandatory keytype
which determines what other keys are valid (all values are strings).type
can be:video
, where associated keys arecodec
,aspect
,width
,height
,duration
. Only one video stream is allowed.audio
, where associated keys arecodec
,language
,channels
.subtitle
, where the associated key islanguage
.
headers
: a dict of http headers to be set whencmd
is a url.
{
'media': {
'duration': '12:34',
'size': '7654321',
'streams': [
{'type': 'video', 'width': '720', 'height': '480'},
{'type': 'audio', 'channels': '2'},
{'type': 'subtitle', 'language': 'eng'},
{'type': 'subtitle', 'language': 'jpn'}
]
},
'headers': { 'User-Agent': 'my ua', 'Cookie': 'foo=x; bar=y;'}
}
(name, cmd, thumb=None, type=PMS_VIDEO, details=None)
-
Add an incomplete media item whose final uri/url will be resolved at playback, where
cmd
is either:- a command array (a python list, or a string in array notation syntax) that when executed will deliver the final url either via
the API (
addVideo
,addAudio
etc) or by printing it to stdout. - a url resolvable by the built-in resolver support (e.g. via kodi or youtube-dl if installed).
- a command array (a python list, or a string in array notation syntax) that when executed will deliver the final url either via
the API (
type
is the item's expected media type - seeaddItem
.name
,thumb
,mediainfo
- seeaddItem
.
(name, cmd, thumb=None, playback=None)
-
Add an mpeg video item to launch a command that ultimately produces video, where
name
is the item's label (or unix-style path), seeaddItem
.cmd
is the command to be executed when the user clicks the item, and can include the${filename}
,${outfile}
, and${home}
runtime variables. seecmd
underaddPlayer
.thumb
is the item's thumbnail image, seethumb
underaddItem
..playback
is a string to control delay and buffering, see addPlayer.
pms.ok()
, pms.info()
and so on in your script.
(name, cmd, ok='Success', fail='Failed', thumb=None)
-
Add an mpeg video item to run a command and automatically show a video message based on the
outcome, where
ok
is the message to display if its exit code is 0.fail
is the message to display if its exit code is non-zero.name
,cmd
,thumb
- seeaddAction
.
(name, cmd, thumb=None)
-
Add an mpeg video item to run a command and automatically show its console output as a
video, where
name
,cmd
,thumb
- seeaddAction
.
(name, format, cmd, thumb=None)
-
Add a generic media item containing properties set by the user which will presumably
be handled by a corresponding user-defined player, where
name
is the item's label (or unix-style path), seeaddItem
.format
is a string specifying the item's media format, followed by optional user-defined properties in the form:media_format:delay_seconds:buffer_mb+userdata
delay_seconds:buffer_mb
uses the syntax ofplayback
inaddplayer
.userdata
is any string defined by you.
foo foo+myFooData foo:10+myFooData foo:-1:20+myFooData
cmd
is the command to be executed when the user clicks the item, and can include the${filename}
,${outfile}
,${format}
,${userdata}
, and${home}
runtime variables. seecmd
underaddPlayer
.thumb
is the item's thumbnail image, seethumb
underaddItem
..
(path=None)
path
is a path segment to be prefixed to the system PATH when the item is executed in the future.- You typically set this once at the beginning, after which any descendants will inherit it. Its value builds incrementally, and
can be cleared to its initial value for the current folder using
pms.addPath()
with path omitted. - For python scripts
path
will also be appended toPYTHONPATH
.PYTHONPATH
tells python where to import any uninstalled modules you may be using.
(name=None, val=None)
-
Define an environment variable to be set when the current folder or its descendants are executed in the future. Also
pms.setEnv('foo')
with noval
will remove the variable 'foo'.pms.setEnv()
without args will clear the current user-defined variables.
()
- Get jumpy's version.
()
- Get jumpy's home path.
()
- Get the local IP of PMS/UMS.
()
- Get the name of the current xmb folder.
()
- Get the full path of the current xmb folder.
(path, thumb=None)
- Create the given (unix-style)
path
on the xmb and set
thumb
as the end folder's thumbnail.
()
- Get the path to the PMS profile directory's 'jumpy' subfolder (where confs can be read/written).
()
- Get the PMS log path (where logs can be written).
()
- Get the path to the running jumpy.jar.
(obj)
- Register a python object with the java side. This is currently for
asynchronous commands (i.e. with '
&
' as the last argument)
to signal "ready" if they have first
requested a temporary suspension of execution in java by setting
pms_await
prior to importing jumpy. For example:pms_await = True # request java execution to halt import jumpy # ... # init pms.register(True) # signal java execution to proceed # ... # asynchronous activity
(up=0)
- Mark the current folder and its ancestors n levels
up
for refresh. Note that how
and when the refresh actually takes effect is renderer-dependent, usually requiring re-entry into
the folder on the xmb.
()
- Restart PMS' http server.
()
- Restart PMS itself.
(cmd, name=None)
- Run the given command and return its exit code as a string.
- Commands with '
&
' as the last argument (whether in Windows or unix) are launched asynchronously and automatically killed if still alive at program shutdown. - If given,
name
is used to identify the process in the log. Otherwise name is taken from the calling object or executable.
(key)
- Get a previously set session variable from jumpy (or
''
if not found), including the predefined ones below:
librtmp | : | 'true' if ffmpeg is compiled with --enable-librtmp. |
using_librtmp | : | 'true' if librtmp is 'true' and the PMS.conf setting rtmpdump.force is not 'true' . |
libass | : | 'true' if ffmpeg is compiled with --enable-libass. |
(key)
- Remove and return a previously set session variable (or
''
if not found).
(key, val)
- Set a session variable (for later retrieval via
getVar
or popVar
).
(key, fallback='')
- Get a property from PMS.conf, or
fallback
if the property isn't set.
(key, val)
- Set a property in PMS.conf.
(src)
- Get the path to an existing local or cached resource, where
- an existing file
- an icon or image with an +fx string added, in which case it will be generated and cached if it doesn't already exist.
src
is either
(path)
- Set an external subtitles file for the last item added. This function must be called
before adding any other items (requires UMS > 2.3.0 and ffmpeg compiled with --enable-libass).
(settings, section=None)
- Set script metadata and options, where
settings
is a python dict containing any of the following reserved keywords for creating the script's gui panel:_title
: a display name._desc
: a description._icon
: a path to an image file._link
: link(s) in markdown inline format, i.e.[link text](url)
, separated by newline characters if more than one._version
: its version._conf
: a path to a conf or properties file containing script-specific settings. Jumpy will read the file and include its items in the script's gui panel as follows:- any comments will become tooltips.
- values will be placed in text boxes by default.
- if a setting's comment contains the exact text '(true|false)' its value will be rendered as a checkbox instead.
readConf
to read user-edited settings correctly.
- any other keys found in the dict will be displayed as regular script settings.
- any setting name beginning with '
$
' will be considered "global" and saved to PMS.conf instead.
section
, if given, designates a configuration section to be internally maintained by jumpy, meant mostly for its own built-in components (e.g. Resolver) and would not typically be set by an external user script.
(filename)
- Read the conf file
filename
as well as its user copy, if any, in the profile section
and return the current settings as a python dict.
(name, cmd, supported, type=PMS_VIDEO, purpose=PMS_MISC_PLAYER, desc=None, icon=None, playback=None, priority=0)
where
name
is the player's name.cmd
is the command PMS will invoke to play matching media with your player, and can include these runtime variables:${filename}
which expands to the media item's full path.${outfile}
which expands to the output file where your player's data stream should be written.${format}
which expands to the media item's format name.${userdata}
which expands to any userdata attached if the item was created usingpms.addMedia()
.${home}
which expands to the jumpy home folder.
"c:\myplayer.bat ${filename} ${outfile}"
supported
is a string specifying supported media in the same syntax used for configuring renderers (see PMS.conf). For instance an "audio as video" player might use:"f:flac|wav m:video/mpeg"
f:
(format) is the only required parameter in thesupported
string.- if omitted,
m:
(mimetype) will default to PMS' default mimetype for the primary format given byf:
. - If
f:
specifies known formats, your player will override PMS' default player for those formats. In this case, since the media is known and can be parsed, you can further narrowsupported
using the other valid parameters (v: a: n:
etc). - If
f:
specifies unrecognised formats (real such asf:txt
or imaginary such asf:foo
), then onlym:
will be valid, since PMS obviously can't parse the media and presumably your player knows what to do anyway. - If you need to specify several different
supported
lines separate them with commas in your string (this feature is as yet untested).
type
is the general media type(s) handled by the player, given by these constants
(which can be combined by bitwise OR):
PMS_AUDIO PMS_IMAGE PMS_VIDEO PMS_UNKNOWN
purpose
determines the player's category in the PMS transcode tab,
and is one of these constants:
PMS_VIDEO_SIMPLEFILE_PLAYER PMS_AUDIO_SIMPLEFILE_PLAYER PMS_VIDEO_WEBSTREAM_PLAYER PMS_AUDIO_WEBSTREAM_PLAYER PMS_MISC_PLAYER
desc
is a description of the player to be included in the PMS transcode tab.
icon
is the default icon to use for the player's supported formats, usage is
identical to img
in pms.setIcon()
.
playback
is a string to modify the player's default playback behavior where
- the format is
delay_seconds:buffer_mb
, e.g.15:20
for a 15 second delay and 20mb buffer. - you can omit buffer, e.g. just
15
for a 15 second delay -1
means 'default' for either variable, e.g.-1:20
for default delay and 20mb buffer.
priority
is the player's relative position in the PMS engine list, where
0
sets it as the default player for its supported formats , i.e. at the front of the list.-1
means it's a secondary player (i.e. included in the #--TRANSCODE--# folder).
(fmt, img)
-
Set the default xmb icon for the given format(s), where
fmt
is one or more formats separated by '|
', e.g. 'foo|bar
'img
is either a filename or named icon and can be appended with an optional +fx string.
(msg, seconds=7)
pms.ok
(msg, seconds=7)
pms.warn
(msg, seconds=7)
pms.err
(msg, seconds=7)
- Output a dvd-ntsc video showing
msg
printed under the relevant icon for
the specified number of seconds
.
These are convenience functions for pms.vmsg()
and will automatically output
to the current ${outfile}
.
(msg)
- Write
msg
to jumpy.log, debug.log and the gui log tab.
(
seconds = 10, # duration
msg = "", # message string
file = None, # (or) text file
out = (automatic), # output file
countdown = False, # whether to show a mm:ss countdown
# ** see imagemagick text docs
fill = 'white', # ** i.e. -fill
background = 'black', # ** i.e. -background
pointsize = 20, # ** i.e. -pointsize
font = "DejaVu-Sans-Mono-Book", # ** i.e. -font
density = 75, # ** i.e. -density
gravity = None, # ** i.e. -gravity
rate = '1', # input rate (images/sec)
img = None, # background image (file or named icon)
imggrav = 'center', # ** i.e. -gravity for img
resize = False, # whether to 'best fit' img
native = False, # whether to generate output at native (real time) frame rate
silence = False # whether to generate a silent audio track
)
- Output a custom dvd-ntsc video showing
msg
with an optional countdown and
background image. This is a variadic named argument function which means the
parameters are all optional and need to be specified by name, e.g.
pms.vmsg(seconds=12, msg='hello ', countdown=True)
$pms vmsg seconds=12 msg='hello ' countdown=True
out
doesn't actually need to be specified, it will be automatically
resolved to the current ${outfile}
.
For details please see the script jumpy/lib/vmsg.py, basically a front-end
for imagemagick convert.
(imgfile, fx, dir=None)
- Apply the specified effects to the given image and save it for later use as a thumbnail or icon,
where
-
imgfile
is the input image file. -
fx
is a semicolon-separated list of any of these operations:f=color
- use this fill, where color is an imagemagick named color,#rrggbb
hex color or other supported color code.r=wxh
- resize to this width x height in pixels.t=SRT
- apply these imagemagick SRT (scale-rotate-transform) operations (with underscores substituted for spaces).c=crop
- crop to this imagemagick crop geometry.h
- flip horizontal, i.e. flop.v
- flip vertical, i.e. flip.3
- apply a 3D effect.s
- apply a shadow effect.g
- apply a gel effect.
-
dir
is the directory to save the rendered image in, and defaults to the current directory if omitted.
This function doesn't normally need to be called directly and is invoked in the background whenever any
thumb
, img
, or icon
argument to the other api functions is appended with a
+fx string.
For details please see the script jumpy/lib/imgfx.py, another front-end
to imagemagick convert.Scripts In Other Languages
-
Jumpy defines a
- unix shell:
- Windows batch file:
- perl:
- unix shell:
- Windows batch file:
- perl:
- Windows batch file:
pms
environment variable which scripts in any
language can use to make API calls via the system. Any API call, for instance
pms.addFolder("Hello", "echo hello")
$pms addFolder Hello "echo hello"
%pms% addFolder Hello "echo hello"
`$ENV{'pms'} addFolder Hello "echo hello"`
For API functions that return a string, such as
pms.getProperty("ffmpeg.path")
:
ffmpeg=$($pms getProperty ffmpeg.path)
for /f "delims=" %%i in ('%pms% getProperty ffmpeg.path') do set ffmpeg=%%i
my $ffmpeg = `$ENV{'pms'} getProperty ffmpeg.path`
Keep in mind that these are system calls and you need to quote/escape your strings as appropriate. To avoid embedded quotes addItem also supports a special array notation syntax to describe your command array as a single string when your args contain spaces, for example:
%pms% addFolder Hello "[echo , hello world]"
Array notation syntax is useful when scripts are using some flavor of
$0
to call themselves back in the future. In general we don't automatically know whether $0
contains spaces or not, and without array notation syntax would need to embed it in quotes to guard against
spaces when making system calls to the API, e.g. \"$0\"
or ""%~0""
and so on
(see Examples).
Players
-
Players are scripts that define a set of supported media formats and output a media
stream to the destination file designated by PMS when items matching these formats are
sent to them. This process, which we'll illustrate using the
webreader player (see jumpy/webreader/webreader.py)
as an example, involves two phases:
Setup
-
The script is identified as a startup
[+]
item in
jumpy-scripts.ini with a startup command defined by you
[+webreader]
cmd = "${home}/webreader/webreader.py" init
which generates an initial call where the script registers itself as a player by calling
pms.addPlayer()
to
define what formats it accepts and what command to issue for playback. For instance
# create the player pms.addPlayer( name = 'webreader', cmd = [sys.argv[0], '${filename}', '${outfile}', '${format}:${userdata}'], supported = 'f:webpage|rdb|readability m:video/mpeg', mediatype = PMS_VIDEO, purpose = PMS_MISC_PLAYER, desc = 'Browse snapshots of your webpages.', playback = '-1' if len(sys.argv) < 3 else sys.argv[2])here the playback command
cmd
is a callback to the same script with runtime
variables as arguments, and will produce calls such as
webreader.py http://nytimes.com/ /tmp/ps3mediaserver/1346412874907webreader webpage:and
supported
declares that video/mpeg
is the mimetype to be broadcast
for items matching the formats webpage|rdb|readability
.
Although supported
can include valid formats understood by PMS too, note that these
three happen to be psuedo-formats meaningful only to the player itself,
and represent custom items that are added to the xmb by calls to
pms.addMedia()
elsewhere in this or other scripts, e.g.
pms.addMedia('NYT Front Page', 'webpage', 'http://nytimes.com/')
Default icons for the new formats are declared next. Here two predefined icons are being used, but they could be image files too:
pms.setIcon('webpage', '#globe')
pms.setIcon('readability|rdb', '#page')
Playback
-
This phase is entirely up to you, the only requirement being that a media stream
eventually be written to the designated
${outfile}
. For instance given
the example above webreader.py ends up doing something like
convert ... | ffmpeg -y ... /tmp/ps3mediaserver/1346412874907webreaderIn Windows the
${outfile}
names are somewhat shell and escape unfriendly and
may end up being mangled. As a workaround
the environment variable %OUTFILE%
(or $OUTFILE
in unix) is also always
set to this filename and the more robust method is to retrieve it there directly.
Note that although the example given here is in python, players, like other scripts, can be written in any language using command-line syntax.
Interpreters
-
Jumpy has automatic support for these file-types:
py, sh, pl, rb, php, groovy, vbs, js
which is to say it associates each with an interpreter, namely:
python, sh, perl, ruby, php, groovy, (windows:cscript), (windows:cscript mac:jsc unix:rhino)
and checks to see if PMS.conf contains a
.path
for the interpreter's executable.
The point of all this is to allow scripts to specify commands in a generic form, which is more
conducive to script-sharing, and let jumpy resolve the details according to each user's settings.
To enable automatic support for one of these interpreters when it isn't installed system-wide, or to pick a specific installed version, add a
.path
setting for it in PMS.conf, for instance
perl.path = /usr/local/lib/perl-5.10.1/bin/perl
Enabling automatic support for a new language involves adding its filetype to script.filetypes
(create it if it doesn't exist) and setting its .interpreter
and .path
in PMS.conf.
For a concrete example we'll pretend that perl isn't already supported and we're adding it as a new
language. We add these settings in PMS.conf:
script.filetypes = py,vbs,js,pl pl.interpreter = perl perl.path = /usr/local/lib/perl-5.10.1/bin/perland now jumpy can resolve everything automatically. For example given the generic command
perl foo.pl arg1 arg2
Jumpy will look for 'perl.path
' and
substitute it if it's present, and if not it will try running the command as-is.
If the given command omits the interpreter:
foo.pl arg1 arg2
(for instance as a result of using $0
) jumpy will first look up the interpreter by file-type,
i.e. 'pl.interpreter
' and then proceed as above.
Icons
-
The names of the icons below (from
raphaeljs,
gnome-stencils,
plus a few of my own) can be substituted for a filename anywhere a
thumb
, img
, or icon
is used in the api, e.g.
pms.addAction('greetings', 'echo Hello', '#smile')
Click on any icon to see it full size (160x160):
|
|
You can also control the color, orientation, location, size as well as rendering effects by adding a +fx string to the name:
#frown |
#smile+f=gold;s |
#wink+t=79,79_30; |
+fx strings work with regular filenames too, for instance to stream a video message with a custom image flipped upside down and shadow added:
pms.vmsg(msg='Not all those who wander are lost.',
img='c:\bag-end\bilbo.png+v;s',
background='SpringGreen', imggrav='west')
Jumpstarting Scripts
-
Jumpstart is a console utility to speed up development by testing
scripts and navigating folders outside of PMS. To see how it works first edit the 3 user-specific paths in
plugins/jumpy/jumpstart.bat if necessary and then open up a console there and type
jumpstart xbmc.pyor
jumpstart c:\somewhere\myscript.bat
Examples
-
These examples are all equivalent, somewhat contrived and don't do anything very useful,
but hopefully they get the essential points across. They're all included in the examples
folder, and to try one out in PMS enable the corresponding section in
examples\examples.ini by removing the '#':
[#+hello.bat]
cmd = ${home}/examples/hello.bat
You can also try it in a console using jumpstart like so:
jumpstart c:\path\to\hello.batFor more practical examples have a look at:
- jumpy/xbmc.py
- jumpy/webreader/webreader.py
- jumpy/examples/httpserver.py
import sys, os, jumpy # initial call: if len(sys.argv) == 1: # add some folders pms.addFolder('Examples/python/Hello', [sys.argv[0], 'hello']) pms.addFolder('Examples/python/Version', [sys.argv[0], 'jumpy version']) # set the environment variable $foo pms.setEnv('foo', 'This is a test') # and add an action to retrieve it later pms.addFolder('Examples/python/Test Env', [sys.argv[0], 'env']) # add an action to display the output of a command pms.addConsoleCmd('Examples/python/Date', 'date') # add an action to start a background process # note also the custom icon and message if sys.platform.startswith('win32'): cmd = 'cmd /c start "jumpy async example" netstat 10' else: cmd = 'xterm -title "jumpy async example" -e netstat -c &' pms.addCmd('Examples/python/netstat', cmd, \ '#two-way', 'netstat console launched on computer') # callbacks: elif sys.argv[1] == 'hello': # add a video item pms.addVideo('World', 'world.mpg') elif sys.argv[1] == 'jumpy version': # add an action specifying an api command in array notation syntax # to stream jumpy's version as a video message pms.addAction('show', ['pms', 'info', 'Jumpy version %s' % pms.version()]) elif sys.argv[1] == 'env': # stream a video message showing the value of '$foo' pms.info("foo = '%s'" % os.getenv('foo'))
#!/bin/sh case "$1" in # initial call: ("") # add some folders (note the embedded quotes: '$0') $pms addFolder Examples/sh/Hello "'$0' hello" # add a folder using array notation syntax # instead of embedded quotes $pms addFolder Examples/sh/Version "[$0 , jumpy version]" # set the environment variable '$foo' $pms setEnv foo "This is a test" # and add an action to retrieve it later $pms addAction "Examples/sh/Test Env Var" "'$0' env" # add an action to display the output of a command $pms addConsoleCmd Examples/sh/Date date # add an action to start a background process (note the final '&') # note also the custom icon and message $pms addCmd "Examples/sh/netstat" \ "xterm -title 'jumpy async example' -e netstat -c &" \ "#two-way" "netstat console launched on computer" ;; # callbacks: (hello) # add a video item $pms addVideo World world.mpg ;; ("jumpy version") # add an action specifying an api command in array notation syntax # to stream jumpy's version as a video message $pms addAction show "[pms , info , Jumpy version $($pms version)]" ;; (env) # stream a video message showing the value of '$foo' $pms info "foo = '$foo'" ;; esac
#!/usr/bin/perl our $pms = $ENV{"pms"}; # initial call: if (not @ARGV) { # add a folder (note the embedded quotes: '$0') `$pms addFolder Examples/perl/Hello "'$0' hello"`; # add a folder using array notation syntax # instead of embedded quotes `$pms addFolder Examples/perl/Version "[$0 , jumpy version]"`; # set the environment variable $foo `$pms setEnv foo "This is a test"`; # and add an action to retrieve it later `$pms addAction "Examples/perl/Test Env Var" "'$0' env"`; # add an action to display the output of a command `$pms addFolder Examples/perl/Date "'$0' date"`; # add an action to start a background process # note also the custom icon and message my $cmd = ($^O eq 'MSWin32' ? "cmd /c start \"jumpy async example\" netstat 10" : "xterm -title 'jumpy async example' -e netstat -c &"); `$pms addCmd "Examples/perl/netstat" "$cmd" "#two-way" "netstat console launched on computer"` } # callbacks: elsif ($ARGV[0] eq 'hello') { # add a video item `$pms addVideo World world.mpg`; } elsif ($ARGV[0] eq 'jumpy version') { # get jumpy's version my $ver = `$pms version`; # and add an action specifying an api command in # array notation syntax to stream it as a video message `$pms addAction show "[pms , info , Jumpy version $ver]"`; } elsif ($ARGV[0] eq 'env') { # stream a video message showing the value of '$foo' `$pms info "foo = '$ENV{'foo'}'"`; }
@echo off setlocal ENABLEDELAYEDEXPANSION :: initial call: if "%~1" == "" ( :: add a folder (note the embedded quotes: ""%~0"") %pms% addFolder Examples/bat/Hello """%~0"" hello" :: add a folder using array notation syntax instead of embedded quotes %pms% addFolder Examples/bat/Version "[%~0 , jumpy version]" :: set the environment variable 'foo' %pms% setEnv foo "This is a test" :: and add an action to retrieve it later %pms% addAction "Examples/bat/Test Env Var" """%~0"" env" :: add an action to display the output of a command %pms% addConsoleCmd "Examples/bat/Date" "date" :: add an action to start a background process :: note also the custom icon and message %pms% addCmd "Examples/bat/netstat" ^ "cmd /c start ""jumpy async example"" netstat 10" ^ "#two-way" "netstat console launched on computer" exit ) :: callbacks: if "%~1" == "hello" ( :: add a video item %pms% addVideo World world.mpg ) else if "%~1" == "jumpy version" ( :: get jumpy's version for /f "delims=" %%i in ('%pms% version') do set ver=%%i :: and add an action specifying an api command in :: array notation syntax to stream it as a video message %pms% addAction show "[pms , info , Jumpy version !ver!]" ) else if "%~1" == "env" ( :: stream a video message showing the value of 'foo' %pms% info "foo = '%foo%'" )