How to connect to vnc using jython?

Asked by Dmitrii

How to connect to vnc using jython?

My simple script:

import unittest
import org.sikuli.script.SikulixForJython
from sikuli import *

class Test_Thing1(unittest.TestCase):

   def setUp(self):
    wait(2)
    Debug.on(4)
    vnc = vncStart("192.168.3.15",5900)
    Test = vnc.capture();
    Test.save("test.png");

if __name__ == '__main__':

   suite = unittest.TestLoader().loadTestsFromTestCase(Test_Thing1) #give the class name
   runner = unittest.TextTestRunner()
   failures = runner.run(suite)
   sys.exit(not failures.wasSuccessful())

Return error:

Traceback (most recent call last):
  File "example.py", line 16, in setUp
    Test = vnc.capture();
AttributeError: 'NoneType' object has no attribute 'capture'

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

vnc = vncStart("192.168.3.15",5900)

you have to check wether vnc is not None before proceeding.

The internal error checking is not that gorgeous ;-) so if the connection fails you will get back None.

So be sure a connection is possible.

vnc = vncStart("192.168.3.15") # sufficient - 5900 is the default
if not vnc:
    # do something that makes sense ;-)

Can you help with this problem?

Provide an answer of your own, or ask Dmitrii for more information if necessary.

To post a message you must log in.