← Back to team overview

sikuli-driver team mailing list archive

[Bug 1697575] Re: Error reported when using image with pattern match from a image module

 

It is working now after I added the following line:

from sikuli import *


So the main module is now:

from sikuli import *

PYTHONPICPATH="C:/Personal Folders/JD/SikuliXIDE/Screenshots.sikuli"

import os
addImagePath("C:/Personal Folders/JD/SikuliXIDE/Screenshots.sikuli")

myPath = os.path.dirname(getBundlePath()) 
if not myPath in sys.path: sys.path.append(myPath)
sys.path.append(PYTHONPICPATH)

import Screenshots

ScreenshotsObj = Screenshots.Screenshots()
Settings.ClickDelay = 0.1

wait(ScreenshotsObj.Youarenowloggedout)
click(ScreenshotsObj.Youarenowloggedout)
click(ScreenshotsObj.RememberMe)
click(ScreenshotsObj.Username)
click(ScreenshotsObj.Password)
click(ScreenshotsObj.BackToOnlineStoreLink)

** Description changed:

  Sikuli version 1.1.1
  Windows 10 (64 bit)
  Java 1.8
  Python
  Using SikulixIDE
  
  Setup:
  Using two different modules in Python, WebSite2017 imports Screenshots.
  
  "Screenshots" is used to define images and creates an object, it is a separate .sikuli project.
  Screenshots Code:
  class Screenshots():
-     def __init__(self):
-         self.Youarenowloggedout = Pattern("Youarenowloggedout.png").similar(0.72)
-         self.BackToOnlineStoreLink = "BackToOnlineStore.png"
+     def __init__(self):
+         self.Youarenowloggedout = Pattern("Youarenowloggedout.png").similar(0.72)
+         self.BackToOnlineStoreLink = "BackToOnlineStore.png"
  -------------------------------------------------------------------------------------------
  "WebSite2017" is the main execution module and contains the follow script (it is in a different .sikuli project and is the one that is run).
  
  WebSite2017 Code:
  PYTHONPICPATH="C:/Personal Folders/JD/SikuliXIDE/Screenshots.sikuli"
  
  import os
  addImagePath("C:/Personal Folders/JD/SikuliXIDE/Screenshots.sikuli")
  
- myPath = os.path.dirname(getBundlePath()) 
+ myPath = os.path.dirname(getBundlePath())
  if not myPath in sys.path: sys.path.append(myPath)
  sys.path.append(PYTHONPICPATH)
- 
  
  import Screenshots
  reload(Screenshots)
  
  ScreenshotsObj = Screenshots.Screenshots()
  Settings.ClickDelay = 0.1
  
  click(ScreenshotsObj.Youarenowloggedout)
  click(ScreenshotsObj.BackToOnlineStoreLink)
  ===========================================================================
  
  Execution results:
  [error] script [ WebTest2017 ] stopped with error in line 18
  [error] NameError ( global name 'Pattern' is not defined )
  [error] --- Traceback --- error source first line: module ( function ) statement 3: Screenshots ( __init__ ) self.Youarenowloggedout = Pattern("Youarenowloggedout.png").similar(0.72)
  [error] --- Traceback --- end --------------
  
  ===========================================================================
  Identified Problem:
  If the image in Screenshots doesn't have an adjustment for pattern matching then the WebSite2017 script executes without problems.
  
  I modified the pattern match for the image in Screenshots (changed to
  0.72) and the error occurs.
  
  The variable created in Screenshots "Youarenowloggedout" doesn't get
  assigned properly in WebSite2017.

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1697575

Title:
  Error reported when using image with pattern match from a image module

Status in Sikuli:
  Invalid

Bug description:
  Sikuli version 1.1.1
  Windows 10 (64 bit)
  Java 1.8
  Python
  Using SikulixIDE

  Setup:
  Using two different modules in Python, WebSite2017 imports Screenshots.

  "Screenshots" is used to define images and creates an object, it is a separate .sikuli project.
  Screenshots Code:
  class Screenshots():
      def __init__(self):
          self.Youarenowloggedout = Pattern("Youarenowloggedout.png").similar(0.72)
          self.BackToOnlineStoreLink = "BackToOnlineStore.png"
  -------------------------------------------------------------------------------------------
  "WebSite2017" is the main execution module and contains the follow script (it is in a different .sikuli project and is the one that is run).

  WebSite2017 Code:
  PYTHONPICPATH="C:/Personal Folders/JD/SikuliXIDE/Screenshots.sikuli"

  import os
  addImagePath("C:/Personal Folders/JD/SikuliXIDE/Screenshots.sikuli")

  myPath = os.path.dirname(getBundlePath())
  if not myPath in sys.path: sys.path.append(myPath)
  sys.path.append(PYTHONPICPATH)

  import Screenshots
  reload(Screenshots)

  ScreenshotsObj = Screenshots.Screenshots()
  Settings.ClickDelay = 0.1

  click(ScreenshotsObj.Youarenowloggedout)
  click(ScreenshotsObj.BackToOnlineStoreLink)
  ===========================================================================

  Execution results:
  [error] script [ WebTest2017 ] stopped with error in line 18
  [error] NameError ( global name 'Pattern' is not defined )
  [error] --- Traceback --- error source first line: module ( function ) statement 3: Screenshots ( __init__ ) self.Youarenowloggedout = Pattern("Youarenowloggedout.png").similar(0.72)
  [error] --- Traceback --- end --------------

  ===========================================================================
  Identified Problem:
  If the image in Screenshots doesn't have an adjustment for pattern matching then the WebSite2017 script executes without problems.

  I modified the pattern match for the image in Screenshots (changed to
  0.72) and the error occurs.

  The variable created in Screenshots "Youarenowloggedout" doesn't get
  assigned properly in WebSite2017.

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1697575/+subscriptions


References