Top Banner
OSDC 2013 - Paris Building and testing under CI a desktop application written in Python using Qt, nose and Jenkins Antoine Taillefer [email protected]
28

Building and testing a desktop application written in Python

Jan 27, 2015

Download

Technology

Nuxeo

This presentation at OSDC 2013 discusses building and testing under CI a desktop application written in Python using Qt, nose and Jenkins.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building and testing a desktop application written in Python

OSDC 2013 - Paris

Building and testing under CIa desktop application written in

Python using Qt, nose and Jenkins

Antoine [email protected]

Page 2: Building and testing a desktop application written in Python

2

About me – Antoine Taillefer

• Graduated from ENSEEIHT in 2006

• Worked for 5 years for an Open source solutions integrator

• Working at Nuxeo since 2011

✔ Software engineer

✔ Involved in consulting / training

• Languages :

✔ Java

✔ Python

Page 3: Building and testing a desktop application written in Python

3

Agenda

• Introduction: Nuxeo & Nuxeo Drive

• Nuxeo Drive architecture

• Coding session

• Build and continuous integration

• Roadmap

Page 4: Building and testing a desktop application written in Python

4

Introduction

Page 5: Building and testing a desktop application written in Python

5

Useful links

• Source code: github.com/nuxeo/nuxeo-drive

• Documentation: doc.nuxeo.com

• Continuous integration: qa.nuxeo.org

• Backlog: jira.nuxeo.com - "Nuxeo Drive"

• Nuxeo: nuxeo.com / nuxeo.org

Page 6: Building and testing a desktop application written in Python

6

Nuxeo Platform

• Open source content management platform

• Repository available through:

✔ Web user interface

✔ REST services (Nuxeo Drive)

✔ Shell

• Java based

● Modular and extensible => build business apps

● Configuration tools: Nuxeo Studio / Nuxeo IDE

Page 7: Building and testing a desktop application written in Python

7

Demo

Page 8: Building and testing a desktop application written in Python

8

Nuxeo Drive

• Fully open source, on Github, LGPL

• Desktop client for Nuxeo

• Available for Windows and OS X

• Roundtrip synchronization

• Selection of the folders to synchronize

• Synchronization of any type of content

• Conflict management (allows offline work)

• Quick edit

Page 9: Building and testing a desktop application written in Python

9

Main features

• Command line

• Systray GUI

• Background synchronization

• Robust to network errors: goes offline

• Token based authentication + revocation

• Multiple server bindings

Page 10: Building and testing a desktop application written in Python

10

Demo

Page 11: Building and testing a desktop application written in Python

11

Architecture

Page 12: Building and testing a desktop application written in Python

12

Server-side

• Addon for Nuxeo

• Token authentication service

• Change detection based on audit log

• Pluggable service layer

• REST API: basic operations

✔ getChanges()

✔ downloadFile()

✔ createFile()

Page 13: Building and testing a desktop application written in Python

13

Client-side

• UI thread / Synchronization thread

• Local storage: maintain pair states

• Token based authentication

• Local file system client

• Remote HTTP client (JSON)

• Synchronization: infinite loop

✔ Polling for remote changes

✔ File system scan for local changes

✔ Resolution and synchronization

Page 14: Building and testing a desktop application written in Python

14

Main libraries

• Threading: threading

• Command-line : argparse

• GUI: PyQt4 (GPL)

• Storage / ORM: sqlalchemy

• OS detection: sys

• File system: os

• HTTP exchanges: urllib2, json, poster

• Logging: logging

• Testing: nose

Page 15: Building and testing a desktop application written in Python

15

Coding session

Page 16: Building and testing a desktop application written in Python

16

Dev tools

• git

• vi / Sublime Text / Eclipse + PyDev

• nose (+ ipdbplugin) / PyUnit

• Jenkins

Page 17: Building and testing a desktop application written in Python

17

Test Driven Development (TDD)

• Goal: PDF conversion of locally synchronized files

• Steps :

✔ Write test scenario

✔ Write test

✔ Run it with nose / PyUnit => should fail

✔ Implement feature

✔ Run test again => should succeed

Page 18: Building and testing a desktop application written in Python

18

GUI with PyQt

• Goal: add menu entry to open the PDF conversion output folder

• Steps:

✔ Code function

✔ Add menu action

● Testing the PyQt GUI?

✔ Simulating clicks with PyQt API by sending signals

✔ PyQt QTest + unittest

✔ TDriver

✔ Squish

Page 19: Building and testing a desktop application written in Python

19

Build under continuous integration

Page 20: Building and testing a desktop application written in Python

20

Goal

• Build standalone binary packages

✔ For Windows: .msi

✔ For OS X: .dmg

● Embed Python, Qt, PyQt and all required libraries

● Don't interfere with already installed packages

Page 21: Building and testing a desktop application written in Python

21

Build environment setup

• Install Python 2 (using Homebrew for OS X)

• Install Qt / PyQt

✔ Linux: sudo apt-get install python-qt4

✔ OS X: sudo brew install pyqt

✔ Windows: install binary package

● Install pip with setuptools: sudo easy_install pip

● Install freeze program

✔ Os X: pip install py2app

✔ Windows: install cx_Freeze

Page 22: Building and testing a desktop application written in Python

22

Application freeze

• Clone nuxeo-drive from Github

git clone https://github.com/nuxeo/nuxeo-drive.git

● Grab dependencies

sudo pip install -r requirements.txt

• Run freeze

• Windows

python.exe setup.py --freeze –dev bdist_msi

• OS X

python setup.py py2app

sh tools/osx/create-dmg.sh

Page 23: Building and testing a desktop application written in Python

23

Demo

Page 24: Building and testing a desktop application written in Python

24

Continuous integration

• Jenkins

• Several jobs

✔ Build Nuxeo addon with Maven

✔ Freeze for Windows => msi

✔ Freeze for OS X => dmg

✔ Functional tests (depends on previous jobs)

➔ Launch Nuxeo server with Drive addon

➔ Run tests with nose

Page 25: Building and testing a desktop application written in Python

25

Roadmap

Page 26: Building and testing a desktop application written in Python

26

Nuxeo 5.8

• HTTP proxy

• Handle readonly documents

• GUI improvements

✔ Unified settings menu

✔ Home folder configuration

✔ Status icon

✔ Last synchronization date

Page 27: Building and testing a desktop application written in Python

27

Nuxeo 5.x

• GUI improvements

✔ Notifications ("10 files synchronized in 8 seconds")

✔ Recently modified files

✔ Suspend synchronization

✔ Multiple server bindings

• Versioning and auto-upgrade

• Explorer / Finder decoration + Right click

• Optimization of local changes detection

Page 28: Building and testing a desktop application written in Python

28

Questions