Indigo Web Server plug-in architecture (alpha 1)

Posted on
Sun Aug 24, 2008 12:56 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Indigo Web Server plug-in architecture (alpha 1)

bluenoise wrote:
What should I look for to fix this? I have EvoCam providing the image as needed to the folder described.

Did you stop and restart the Indigo Server so that the Python source files would get recompiled?

Regards,
Matt

Posted on
Sun Aug 24, 2008 5:00 pm
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

Re: Indigo Web Server plug-in architecture (alpha 1)

support wrote:
bluenoise wrote:
What should I look for to fix this? I have EvoCam providing the image as needed to the folder described.

Did you stop and restart the Indigo Server so that the Python source files would get recompiled?

Regards,
Matt


Hi, Matt-

Thank you for the reply. I actually restarted the Mac (for a different reason) and it does not work for me. The example plug-in "template_example" works fine, though. As a hack/workaround, I have it just load the static image when I click the link on my control page by linking to the actual JPG file in my images folder. I don't think this is as elegant as your solution, though.

Another question while I'm at it...;)

Is there a way to set a cookie or something so that I don't have to enter my login info each time I visit from my iPhone? I know I could turn off the security feature, but I don't want to do that (yet).

-Marc

EDIT: I figured something out...I did not realize Python is sensitive to indentation. I double-clicked the .py file and got a syntax error due to incorrect indentation. I've corrected it and now it compiles happily. However, I just get a blank white page when I click my camera link, but there is no error message now.

Posted on
Sun Aug 24, 2008 5:21 pm
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

(No subject)

OK, problems have been solved. I had altered the path variable in my HTML hoping it was the cause of my problems. I have corrected it back to 'stock' and all is working now.

Thank you again for your attention.

-Marc

Posted on
Fri Oct 03, 2008 3:03 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

(No subject)

Note that because of changes included in the 3.0.6 release some slight modifications may be needed to any Web server plugins you have created or are using.

Specficially, because the Web server is now multithreaded, a locking mechanism is needed when acquiring and using templates. Instances of using the old technique:
Code: Select all
   def cameras(self):
      # Make sure the plug-in template folder path is correct.
      # In this example the plug-in folder must be named "sample."
      tmpl = self._GetPluginTemplate('sample/templates/cameras.html')
      tmpl.requestFromPrism = self._IsRequestFromPrism()
      return tmpl.RenderTemplate()
   cameras.exposed = True

should be changed to use the new methods _GetAndLockPluginTemplate() and ReleaseLock() like this:
Code: Select all
   def cameras(self):
      tmpl = self._GetAndLockPluginTemplate('sample/templates/cameras.html')
      try:
         tmpl.requestFromPrism = self._IsRequestFromPrism()
         return tmpl.RenderTemplate()
      finally:
         tmpl.ReleaseLock();
   cameras.exposed = True

Also remove the following line from the top of the reqhandler.py file:
Code: Select all
from cherrypy import _cputil

Lastly, template files themselves should no longer use the Cheetah #filter command to specify the Indigo filter. That filter is now automatically used by all template files the Web server uses. Therefore, remove all of these lines from the top of your plugin template files:
Code: Select all
#filter $indigoCheetahFilter

Regards,
Matt
Last edited by matt (support) on Sun Oct 05, 2008 11:34 am, edited 1 time in total.

Posted on
Sat Oct 04, 2008 2:43 pm
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

(No subject)

Hi, Matt-

I've made the changes described in your most recent post (after updating to the latest version of Indigo) and my link to my camera view page broke. When I click the link on my control page that used to bring up a new page with my camera view, I get this message in the browser window: "undefined page requested."

Likewise, the log shows this:
Code: Select all
  WebServer          undefined page requested "http://<myserverwebaddress>:8176/sample/cameras" from 75.0.188.198


Strangely, it's looking for sample/cameras.html (with the html extension), but it doesn't show that in the log.

I've verified no syntax errors due to indentation problems as before.

Thanks

-Marc

Posted on
Sun Oct 05, 2008 9:06 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

(No subject)

Start the IndigoWebServer using the Terminal:
Code: Select all
/Library/Application\ Support/Perceptive\ Automation/Indigo\ 2/IndigoWebServer/devhelpers/indigowebstart

Copy/paste the results seen in the Terminal into a forum post for me.

Note that indigowebstart command always starts the web server on the default port (8176). You can edit that shell command to use a different port number for starting it if need be.

Regards,
Matt

Posted on
Sun Oct 05, 2008 9:43 am
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

(No subject)

support wrote:
Start the IndigoWebServer using the Terminal:
Code: Select all
/Library/Application\ Support/Perceptive\ Automation/Indigo\ 2/IndigoWebServer/devhelpers/indigowebstart

Copy/paste the results seen in the Terminal into a forum post for me.

Note that indigowebstart command always starts the web server on the default port (8176). You can edit that shell command to use a different port number for starting it if need be.

Regards,
Matt


Hi, Matt-

Here you go...

-Marc

Code: Select all
Mac-Mini:~ MBF$ /Library/Application\ Support/Perceptive\ Automation/Indigo\ 2/IndigoWebServer/devhelpers/indigowebstart
/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/devhelpers/indigowebstart: line 38: indigowebstop: command not found
Starting IndigoWebServer
Mac-Mini:~ MBF$ [05/Oct/2008:08:37:14]  INDIGO_LOG
[05/Oct/2008:08:37:14]  INDIGO_LOG processing plugin folder /sample
[05/Oct/2008:08:37:14]  INDIGO_LOG - filename: reqhandler.py
[05/Oct/2008:08:37:14]  INDIGO_LOG Traceback (most recent call last):
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/indigopy/indigoplugin.py", line 121, in LoadWebPlugins
    plugin_parent = __import__(modulenameForImport, globals(), locals(), [filename_base])
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/plugins/sample/reqhandler.py", line 23, in <module>
    from cherrypy import _cputil
ImportError: cannot import name _cputil

[05/Oct/2008:08:37:14]  INDIGO_LOG -   enabling static file access to path /sample/images on mounted app _root_
[05/Oct/2008:08:37:14]  INDIGO_LOG -   enabling static file access to path /sample/static on mounted app _root_
[05/Oct/2008:08:37:14]  INDIGO_LOG
[05/Oct/2008:08:37:14]  INDIGO_LOG processing plugin folder /sample/images
[05/Oct/2008:08:37:14]  INDIGO_LOG
[05/Oct/2008:08:37:14]  INDIGO_LOG processing plugin folder /sample/reqhandler.app
[05/Oct/2008:08:37:14]  INDIGO_LOG
[05/Oct/2008:08:37:14]  INDIGO_LOG processing plugin folder /sample/reqhandler.app/Contents
[05/Oct/2008:08:37:14]  INDIGO_LOG
[05/Oct/2008:08:37:14]  INDIGO_LOG processing plugin folder /sample/reqhandler.app/Contents/MacOS
[05/Oct/2008:08:37:14]  INDIGO_LOG
[05/Oct/2008:08:37:14]  INDIGO_LOG processing plugin folder /sample/reqhandler.app/Contents/Resources
[05/Oct/2008:08:37:14]  INDIGO_LOG - filename: __argvemulator_reqhandler.py
[05/Oct/2008:08:37:14]  INDIGO_LOG Traceback (most recent call last):
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/indigopy/indigoplugin.py", line 121, in LoadWebPlugins
    plugin_parent = __import__(modulenameForImport, globals(), locals(), [filename_base])
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/plugins/sample/reqhandler.py", line 23, in <module>
    from cherrypy import _cputil
ImportError: cannot import name _cputil

[05/Oct/2008:08:37:14]  INDIGO_LOG - filename: reqhandler.py
[05/Oct/2008:08:37:14]  INDIGO_LOG Traceback (most recent call last):
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/indigopy/indigoplugin.py", line 121, in LoadWebPlugins
    plugin_parent = __import__(modulenameForImport, globals(), locals(), [filename_base])
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/plugins/sample/reqhandler.py", line 23, in <module>
    from cherrypy import _cputil
ImportError: cannot import name _cputil

[05/Oct/2008:08:37:14]  INDIGO_LOG
[05/Oct/2008:08:37:14]  INDIGO_LOG processing plugin folder /sample/static
[05/Oct/2008:08:37:14]  INDIGO_LOG
[05/Oct/2008:08:37:14]  INDIGO_LOG processing plugin folder /sample/templates
[05/Oct/2008:08:37:14] ENGINE Bus STARTING
CherryPy Checker:
'/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/indigoflash' (root + dir) is not an existing filesystem path.
section: [/indigoflash]
root: '/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer'
dir: 'indigoflash'

[05/Oct/2008:08:37:15]  INDIGO_LOG connecting to Indigo server
[05/Oct/2008:08:37:15]  INDIGO_LOG Authen:  user name green
[05/Oct/2008:08:37:15]  INDIGO_LOG Authen: indigoHash xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[05/Oct/2008:08:37:15]  INDIGO_LOG Authen:    webHash xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[05/Oct/2008:08:37:15]  INDIGO_LOG started on port 8176 -- digest authentication enabled
[05/Oct/2008:08:37:15]  INDIGO_LOG enabled browser access to plugin path "plugins/sample/images"
[05/Oct/2008:08:37:15]  INDIGO_LOG enabled browser access to plugin path "plugins/sample/static"
[05/Oct/2008:08:37:15] ENGINE Started monitor thread '_TimeoutMonitor'.
[05/Oct/2008:08:37:20] ENGINE Error in 'start' listener <bound method Server.start of <cherrypy>>
Traceback (most recent call last):
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/wspbus.py", line 147, in publish
    output.append(listener(*args, **kwargs))
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/_cpserver.py", line 89, in start
    ServerAdapter.start(self)
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/servers.py", line 53, in start
    wait_for_free_port(*self.bind_addr)
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/servers.py", line 209, in wait_for_free_port
    raise IOError("Port %r not free on %r" % (port, host))
IOError: Port 8176 not free on '0.0.0.0'

[05/Oct/2008:08:37:20] ENGINE Shutting down due to error in start listener:
Traceback (most recent call last):
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/wspbus.py", line 180, in start
    self.publish('start')
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/wspbus.py", line 147, in publish
    output.append(listener(*args, **kwargs))
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/_cpserver.py", line 89, in start
    ServerAdapter.start(self)
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/servers.py", line 53, in start
    wait_for_free_port(*self.bind_addr)
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/servers.py", line 209, in wait_for_free_port
    raise IOError("Port %r not free on %r" % (port, host))
IOError: Port 8176 not free on '0.0.0.0'

[05/Oct/2008:08:37:20] ENGINE Bus STOPPING
[05/Oct/2008:08:37:20] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8176)) already shut down
[05/Oct/2008:08:37:20]  INDIGO_LOG disconnecting from Indigo server
[05/Oct/2008:08:37:20] ENGINE Stopped thread '_TimeoutMonitor'.
[05/Oct/2008:08:37:20] ENGINE Bus STOPPED
[05/Oct/2008:08:37:20] ENGINE Bus EXITING
[05/Oct/2008:08:37:20] ENGINE Bus EXITED
Traceback (most recent call last):
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/IndigoWebServer.py", line 272, in <module>
    cherrypy.engine.start()
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/wspbus.py", line 180, in start
    self.publish('start')
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/wspbus.py", line 147, in publish
    output.append(listener(*args, **kwargs))
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/_cpserver.py", line 89, in start
    ServerAdapter.start(self)
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/servers.py", line 53, in start
    wait_for_free_port(*self.bind_addr)
  File "/Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/cherrypy/process/servers.py", line 209, in wait_for_free_port
    raise IOError("Port %r not free on %r" % (port, host))
IOError: Port 8176 not free on '0.0.0.0'

Mac-Mini:~ MBF$


Posted on
Sun Oct 05, 2008 11:33 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

(No subject)

Inside the plugin's reqhandler.py file remove this line (near the top):
Code: Select all
from cherrypy import _cputil

Regards,
Matt

Posted on
Sun Oct 05, 2008 2:11 pm
bluenoise offline
Posts: 143
Joined: Aug 23, 2008

(No subject)

Thank you again, Matt, for your incredibly-prompt solution to my problem! It's working again.

-Marc

Posted on
Sat Feb 14, 2009 5:15 pm
yergeyj offline
Posts: 260
Joined: Dec 29, 2004

(No subject)

OK Matt, I'm pretty sure I got in over my head on this one. :oops:

Is there a current version (not requiring editing of the python and other files) of the "sample" plugin for IWS that works on Indigo 4.0b5? If not, is there a simpler way to serve up a static web page in "Control Pages?" I followed you instructions for implementing the "sample" IWS plug-in, but unfortunately didn't read the entire post, so I didn't note the modifications needed post Indigo 3.0.6.

It seems to work for the static page serving, but also adds the "Sample Plug-in" to the "Control Pages" on the web server, which I don't need and don't know where/how to remove.

All I want is to serve a static web page from my Control Pages or the IWS, and hopefully from Control Pages in the upcoming iPhone app. Specifically, I keep an updated log of calls from Phlink as a formatted web page that I'd like to securely access through the IWS.

Jim

Posted on
Sat Feb 14, 2009 6:14 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

(No subject)

Hi Jim,

It sounds like you have the sample plug-in working. To have it not show up in the Control Page index page, just change this line inside the reqhandler.py file from:
Code: Select all
def ShowOnControlPageList():
   return True      # if True, then above name/description is shown on the Control Page list index

to:
Code: Select all
def ShowOnControlPageList():
   return False      # if True, then above name/description is shown on the Control Page list index

Then stop and restart the server. The plugin will still work (server static pages for you) and will be hidden from the index page.

Image

Posted on
Sun Feb 15, 2009 2:17 pm
yergeyj offline
Posts: 260
Joined: Dec 29, 2004

(No subject)

Thanks Matt,

It works now; no "Sample Plug-in" control page on IWS, but my Phlink log static page loads OK.

BTW, the original for my static page is stored in "/Users/username/Sites." I tried using an alias, but recall that doesn't work in Unix (I got a blank page in IWS), so I created a hard link in Terminal to the original file like so:

ln /Users/username/Sites/index.html /Library/Application Support/Perceptive Automation/Indigo 4/IndigoWebServer/plugins/sample/static/PhlinkLog.html

This shouldn't cause any problems, correct? It's been a while since I did much in Unix, and don't want to crap things up. :oops:

Thanks as always,
Jim

Posted on
Mon Feb 16, 2009 2:21 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

(No subject)

This shouldn't cause any problems, correct?

I think that should be fine. Glad it is up and working for you.

Image

Posted on
Mon Mar 30, 2009 5:59 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

(No subject)

support wrote:
To have it not show up in the Control Page index page, just change this line inside...

Note plug-ins no longer show up on the Control Page index page; they are on the main home page instead.

Image

Posted on
Tue Aug 31, 2010 7:14 am
jenkins007 offline
Posts: 113
Joined: Nov 08, 2006
Location: Seguin, TX

Using external URL on Control page for both server/prism acc

I use LWC2 Weather App and it creates a nice weather dashboard web page every 15 minutes. I point the app to put the data under the folder structure for Indigo: /Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer/plugins/weather/static folder and, accessing it locally works fine using http://<servername>:8176/weather/static/LWCWeb/index.html.
[I changed the name "sample" to "weather" using your sample template and modified the .py file]

However accessing it remotely through the Prism reflector does not work unless I use this relative path: http://<username>.goprism.com/weather/static/LWCWeb/index.html

Right now I have 2 external links defined on my control page: one for accessing it at home and the other via the Prism reflector. I would like to change this to a relative path so I only use one link regardless of where I access it. I use Satellite internet (live in the country) - and accessing local files remotely is not palatable.

Question: How do I define the link on a control page so it will work regardless of being accessed locally or remotely (going through the Prism Reflector but only for remote requests)?. Is this possible with version 4.1.13?

Thanks,
Matthew

Who is online

Users browsing this forum: No registered users and 5 guests