SlideShare uma empresa Scribd logo
1 de 109
Baixar para ler offline
Tilting at Windmills
         with
ctypes and cygwinreg
        Simon Law
     simon@akoha.com
def introduction():
social reality game
def problem():
website
testing
click
wait
look
click
wait
look
click
wait
look
slow
laborious
boring
automated testing
def test_browser():
© Andy Heatwole
Creative Commons Attribution-NonCommercial-NoDerivs 2.5.
           http://blog.bluehourphoto.com/?showimage=224
getwindmill.com
one script
all browsers
from windmill.authoring import *
def setup_module(module):
  client = WindmillTestClient(__name__)
  client.click(id=u'home')
  client.waits.forPageLoad(timeout=u'60000')
  client.asserts.assertNode(id='LoginPage')
from windmill.authoring import *
def setup_module(module):
  client = WindmillTestClient(__name__)
  client.click(id=u'home')
  client.waits.forPageLoad(timeout=u'60000')
  client.asserts.assertNode(id='LoginPage')
from windmill.authoring import *
def setup_module(module):
  client = WindmillTestClient(__name__)
  client.click(id=u'home')
  client.waits.forPageLoad(timeout=u'60000')
  client.asserts.assertNode(id='LoginPage')
from windmill.authoring import *
def setup_module(module):
  client = WindmillTestClient(__name__)
  client.click(id=u'home')
  client.waits.forPageLoad(timeout=u'60000')
  client.asserts.assertNode(id='LoginPage')
semi-automated testing
def continuous_integration():
test automatically
buildbot.net
~/akoha$ make check
C:>make check
'make' is not recognized as an
internal or external command,
operable program or batch file.
cygwin.com
~/akoha$ make check
Traceback (most recent call last):
  ...
ImportError: No module named _winreg
def windows_registry():
proxy settings
import _winreg
import winreg
32.3. winreg
Windows registry access

  Platforms: Windows
32.3. winreg
Windows registry access

  Platforms: Windows
3 choices
1
give up
2
recompile Python
3
cygwinreg
like hurting myself
def call_system_libraries():
import ctypes
foreign function interface
call functions
shared libraries
libiberty.so
libgcc.dynlib
advapi32.dll
>>> from ctypes import cdll
>>> cdll.advapi32
<CDLL 'advapi32', ... at ...>
>>> cdll.advapi32.RegCloseKey
<_FuncPtr object at 0x...>
>>> a = cdll.advapi32
>>> RegCloseKey = a.RegCloseKey
>>> RegCloseKey(0)
6
no introspection
>>> RegCloseKey(0)
6
>>> RegCloseKey()
6
return value
function arguments
from ctypes import cdll
from ctypes import c_long, c_ulong
# WINADVAPI LONG WINAPI RegCloseKey(HKEY);
RegCloseKey = cdll.advapi32.RegCloseKey
RegCloseKey.restype = c_long
RegCloseKey.argtypes = [c_ulong]
from ctypes import cdll
from ctypes import c_long, c_ulong
# WINADVAPI LONG WINAPI RegCloseKey(HKEY);
RegCloseKey = cdll.advapi32.RegCloseKey
RegCloseKey.restype = c_long
RegCloseKey.argtypes = [c_ulong]
from ctypes import cdll
from ctypes import c_long, c_ulong
# WINADVAPI LONG WINAPI RegCloseKey(HKEY);
RegCloseKey = cdll.advapi32.RegCloseKey
RegCloseKey.restype = c_long
RegCloseKey.argtypes = [c_ulong]
from ctypes import cdll
from ctypes import c_long, c_ulong
LONG = c_long
HANDLE = c_ulong # in header files: void *
HKEY = HANDLE
# WINADVAPI LONG WINAPI RegCloseKey(HKEY);
RegCloseKey = cdll.advapi32.RegCloseKey
RegCloseKey.restype = LONG
RegCloseKey.argtypes = [HKEY]
>>> RegCloseKey(0)
6
>>> RegCloseKey()
Traceback (most recent call last):
  ...
TypeError: this function takes at
least 1 argument (0 given)
not Pythonic
PyHKEY.Close()

Closes the underlying
  Windows handle.
class PyHKEY(object):
    def __init__(self, hkey):
        self.hkey = hkey
   def Close(self):
       if RegCloseKey(self.hkey) != 0:
           raise WindowsError()
       self.hkey = 0

class WindowsError(OSError):
    ...
class PyHKEY(object):
    def __init__(self, hkey):
        self.hkey = hkey
   def Close(self):
       RegCloseKey(self.hkey)
           raise WindowsError()
       self.hkey = 0

class WindowsError(OSError):
    ...
class PyHKEY(object):
    def __init__(self, hkey):
        self.hkey = hkey
   def Close(self):
       if RegCloseKey(self.hkey) != 0:
           raise WindowsError()
       self.hkey = 0

class WindowsError(OSError):
    ...
>>> from cygwinreg import PyHKEY
>>> hkey = PyHKEY(0)
>>> hkey.Close()
RegDeleteKeyW = cdll.advapi32.RegDeleteKeyW
RegDeleteKeyW.restype = LONG
RegDeleteKeyW.argtypes = [HKEY, LPCWSTR]
def DeleteKey(key, sub_key):
    from cygwinreg.w32api import RegDeleteKeyW
    wincall(RegDeleteKeyW(PyHKEY.make(key),
                          sub_key))
hours later
>>> try:
...      import winreg
... except ImportError:
...      import cygwinreg as winreg
def tradeoffs():
Python only
no compilation
slower
no parsing
simple
not automatic
standard
portable
good enough
def conclusion():
~/akoha$ make check
continuous integration
browser tests
pypi.python.org/pypi/cygwinreg
no compilation
no installation
no :'-(
cygwinreg
pypi.python.org/pypi/cygwinreg
          PSF License



       this presentation:
  Attribution-Share Alike 3.0

Mais conteúdo relacionado

Mais procurados

Обзор фреймворка Twisted
Обзор фреймворка TwistedОбзор фреймворка Twisted
Обзор фреймворка Twisted
Maxim Kulsha
 

Mais procurados (19)

RxJS - 封裝程式的藝術
RxJS - 封裝程式的藝術RxJS - 封裝程式的藝術
RxJS - 封裝程式的藝術
 
c++ program for Canteen management
c++ program for Canteen managementc++ program for Canteen management
c++ program for Canteen management
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
 
The Ring programming language version 1.2 book - Part 28 of 84
The Ring programming language version 1.2 book - Part 28 of 84The Ring programming language version 1.2 book - Part 28 of 84
The Ring programming language version 1.2 book - Part 28 of 84
 
Debugging JavaScript with Chrome
Debugging JavaScript with ChromeDebugging JavaScript with Chrome
Debugging JavaScript with Chrome
 
Rx.NET, from the inside out - Codemotion 2018
Rx.NET, from the inside out - Codemotion 2018Rx.NET, from the inside out - Codemotion 2018
Rx.NET, from the inside out - Codemotion 2018
 
Ee
EeEe
Ee
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲーム
 
Operator Overloading
Operator Overloading  Operator Overloading
Operator Overloading
 
The Ring programming language version 1.7 book - Part 47 of 196
The Ring programming language version 1.7 book - Part 47 of 196The Ring programming language version 1.7 book - Part 47 of 196
The Ring programming language version 1.7 book - Part 47 of 196
 
Node.js flow control
Node.js flow controlNode.js flow control
Node.js flow control
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
Обзор фреймворка Twisted
Обзор фреймворка TwistedОбзор фреймворка Twisted
Обзор фреймворка Twisted
 
QA Fest 2019. Saar Rachamim. Developing Tools, While Testing
QA Fest 2019. Saar Rachamim. Developing Tools, While TestingQA Fest 2019. Saar Rachamim. Developing Tools, While Testing
QA Fest 2019. Saar Rachamim. Developing Tools, While Testing
 
Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8
 
Mysql handle socket
Mysql handle socketMysql handle socket
Mysql handle socket
 
Arp
ArpArp
Arp
 
Universal JavaScript
Universal JavaScriptUniversal JavaScript
Universal JavaScript
 

Destaque

Home Projects (1)
Home Projects (1)Home Projects (1)
Home Projects (1)
Paul Melton
 
Krishna Printernational Corporate Presentation
Krishna Printernational Corporate PresentationKrishna Printernational Corporate Presentation
Krishna Printernational Corporate Presentation
Krishna Printernational
 
Paty y Paloma
Paty y PalomaPaty y Paloma
Paty y Paloma
jesselem
 
Андрей Рыжкин и Никита Степаненко – Инструменты, которые мы любим
Андрей Рыжкин и Никита Степаненко – Инструменты, которые мы любимАндрей Рыжкин и Никита Степаненко – Инструменты, которые мы любим
Андрей Рыжкин и Никита Степаненко – Инструменты, которые мы любим
404fest
 
Panpattana
PanpattanaPanpattana
Panpattana
sakeenan
 

Destaque (20)

More Press...Less Stress
More Press...Less StressMore Press...Less Stress
More Press...Less Stress
 
Innopolis ux course
Innopolis ux courseInnopolis ux course
Innopolis ux course
 
Bdf report finale compresso
Bdf report finale compressoBdf report finale compresso
Bdf report finale compresso
 
Prototype Design Camp, OETC11
Prototype Design Camp, OETC11Prototype Design Camp, OETC11
Prototype Design Camp, OETC11
 
Dec 3 Chapel
Dec 3 ChapelDec 3 Chapel
Dec 3 Chapel
 
Home Projects (1)
Home Projects (1)Home Projects (1)
Home Projects (1)
 
Krishna Printernational Corporate Presentation
Krishna Printernational Corporate PresentationKrishna Printernational Corporate Presentation
Krishna Printernational Corporate Presentation
 
Aftrap BIK Challenge: Samen slim energiezuinig renoveren van huurwoningen in ...
Aftrap BIK Challenge: Samen slim energiezuinig renoveren van huurwoningen in ...Aftrap BIK Challenge: Samen slim energiezuinig renoveren van huurwoningen in ...
Aftrap BIK Challenge: Samen slim energiezuinig renoveren van huurwoningen in ...
 
Album research
Album researchAlbum research
Album research
 
Paty y Paloma
Paty y PalomaPaty y Paloma
Paty y Paloma
 
Андрей Рыжкин и Никита Степаненко – Инструменты, которые мы любим
Андрей Рыжкин и Никита Степаненко – Инструменты, которые мы любимАндрей Рыжкин и Никита Степаненко – Инструменты, которые мы любим
Андрей Рыжкин и Никита Степаненко – Инструменты, которые мы любим
 
Espace Tooth1
Espace Tooth1Espace Tooth1
Espace Tooth1
 
ASL BT Registro tumori 2014
ASL BT Registro tumori 2014ASL BT Registro tumori 2014
ASL BT Registro tumori 2014
 
NEDMA14: Targeting Audiences with Direct Response Campaigns on Mobile - Ted M...
NEDMA14: Targeting Audiences with Direct Response Campaigns on Mobile - Ted M...NEDMA14: Targeting Audiences with Direct Response Campaigns on Mobile - Ted M...
NEDMA14: Targeting Audiences with Direct Response Campaigns on Mobile - Ted M...
 
Recruiting Brochure
Recruiting BrochureRecruiting Brochure
Recruiting Brochure
 
การนำชมห้องสมุด
การนำชมห้องสมุดการนำชมห้องสมุด
การนำชมห้องสมุด
 
Menèame
MenèameMenèame
Menèame
 
Incredable india...
Incredable india...Incredable india...
Incredable india...
 
Panpattana
PanpattanaPanpattana
Panpattana
 
HOLD FAST
HOLD FASTHOLD FAST
HOLD FAST
 

Semelhante a Tilting at Windmills with ctypes and cygwinreg

Samsung WebCL Prototype API
Samsung WebCL Prototype APISamsung WebCL Prototype API
Samsung WebCL Prototype API
Ryo Jin
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010
Chris Ramsdale
 

Semelhante a Tilting at Windmills with ctypes and cygwinreg (20)

Modern c++
Modern c++Modern c++
Modern c++
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
リローダブルClojureアプリケーション
リローダブルClojureアプリケーションリローダブルClojureアプリケーション
リローダブルClojureアプリケーション
 
Sandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooksSandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooks
 
Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)
 
Webauthn Tutorial
Webauthn TutorialWebauthn Tutorial
Webauthn Tutorial
 
Daniel Jalkut - dotSwift 2019
Daniel Jalkut - dotSwift 2019Daniel Jalkut - dotSwift 2019
Daniel Jalkut - dotSwift 2019
 
Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)
 
Dsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in ScalaDsug 05 02-15 - ScalDI - lightweight DI in Scala
Dsug 05 02-15 - ScalDI - lightweight DI in Scala
 
Android Wear Essentials
Android Wear EssentialsAndroid Wear Essentials
Android Wear Essentials
 
Samsung WebCL Prototype API
Samsung WebCL Prototype APISamsung WebCL Prototype API
Samsung WebCL Prototype API
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010
 
A Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to BluemixA Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to Bluemix
 
Side effects-con-redux
Side effects-con-reduxSide effects-con-redux
Side effects-con-redux
 
The Ring programming language version 1.3 book - Part 30 of 88
The Ring programming language version 1.3 book - Part 30 of 88The Ring programming language version 1.3 book - Part 30 of 88
The Ring programming language version 1.3 book - Part 30 of 88
 
Working in the multi-cloud with libcloud
Working in the multi-cloud with libcloudWorking in the multi-cloud with libcloud
Working in the multi-cloud with libcloud
 
Steps how to create active x using visual studio 2008
Steps how to create active x using visual studio 2008Steps how to create active x using visual studio 2008
Steps how to create active x using visual studio 2008
 
Building Better Backdoors with WMI - DerbyCon 2017
Building Better Backdoors with WMI - DerbyCon 2017Building Better Backdoors with WMI - DerbyCon 2017
Building Better Backdoors with WMI - DerbyCon 2017
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Tilting at Windmills with ctypes and cygwinreg