32
Using Python and XMPP to build a decentralized social network erˆ ome Poisson (Goffi) FOSDEM Saturday 30th January 2016

Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Using Python and XMPP to build a decentralizedsocial network

Jerome Poisson (Goffi)

FOSDEM

Saturday 30th January 2016

Page 2: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Some words about the projecta lot of featuresother interfaces

about the technologiesglobal architecture

Python !about the choice of Pythonsome advantages

Twisted

Urwid

PyjamasA New Hope

Things we have learnedSalut a Vous

Page 3: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Some words about the project

Libervia/Salut a Toi is a Multipurpose, multi frontendcommunication tool

Page 4: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Some words about the project

I project started in 2008/2009

I Social Contracthttp://salut-a-toi.org/social_contract.html

I non profit association

Page 5: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Outline

Some words about the projecta lot of featuresother interfaces

about the technologiesglobal architecture

Python !about the choice of Pythonsome advantages

Twisted

Urwid

PyjamasA New Hope

Things we have learnedSalut a Vous

Page 6: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Some words about the project

I instant messaging (of course)

I end 2 end encryption

I P2P file sharing

I blog engine (decentralized !)

I lot of experimentations

Page 7: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def
Page 8: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Outline

Some words about the projecta lot of featuresother interfaces

about the technologiesglobal architecture

Python !about the choice of Pythonsome advantages

Twisted

Urwid

PyjamasA New Hope

Things we have learnedSalut a Vous

Page 9: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def
Page 10: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

other interfaces

I don’t reinvent the wheel

I we use standards (XMPP)

I factorization

Page 11: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Outline

Some words about the projecta lot of featuresother interfaces

about the technologiesglobal architecture

Python !about the choice of Pythonsome advantages

Twisted

Urwid

PyjamasA New Hope

Things we have learnedSalut a Vous

Page 12: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def
Page 13: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Python !

we use Python everywhere we can

I Twisted (backend, web frontend)

I curses Urwid (console frontend)

I Pyjamas (web frontend)

I WxWidgets Kivy to be done

I Jinja (web frontend)

. . . and sometime we don’t

I Qt/C++ (Desktop frontend)

Page 14: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Outline

Some words about the projecta lot of featuresother interfaces

about the technologiesglobal architecture

Python !about the choice of Pythonsome advantages

Twisted

Urwid

PyjamasA New Hope

Things we have learnedSalut a Vous

Page 15: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

about the choice of Python

I speed (execution)

I pypyI cythonI C/C++ inclusion

I speed (development)

I popular (libraries)

I popular (similar projects)

I popular (tools)

Page 16: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

about the choice of Python

I speed (execution)I pypyI cythonI C/C++ inclusion

I speed (development)

I popular (libraries)

I popular (similar projects)

I popular (tools)

Page 17: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

about the choice of Python

I speed (execution)I pypyI cythonI C/C++ inclusion

I speed (development)

I popular (libraries)

I popular (similar projects)

I popular (tools)

Page 18: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

tools

I Mercurial

I BuildBot

I D-Feet

Page 19: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Outline

Some words about the projecta lot of featuresother interfaces

about the technologiesglobal architecture

Python !about the choice of Pythonsome advantages

Twisted

Urwid

PyjamasA New Hope

Things we have learnedSalut a Vous

Page 20: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

some advantages

I debugging (pudb & ipdb)

I stability (Python & Twisted)

I workaround/monkey patching

I standard library (re, argparse, dom, urlparse/urllib)

I Python is fun !

Page 21: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Twisted

I asynchronous

I huge framework

I well thought abstractions

I test driven development

Page 22: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Twisted

I Deferred

def fosdemTalkCb ( s e l f , r e s u l t ) :p r i n t u”OK! {}” . format ( r e s u l t )

def fosdemTalkEb ( s e l f , f a i l u r e ) :p r i n t u” D i s a s t e r ! {}” . format ( f a i l u r e )

d = getFosdemTalkOpin ion ( )d . addCa l l b a ck s ( s e l f . fosdemTalkCb , fosdemTalkEb )

I inline callbacks

@de fe r . i n l i n e C a l l b a c k sdef f o sdemTa lkPo l l ( s e l f ) :

t r y :o p i n i o n = y i e l d getFosdemTalkOpin ion ( )

except BadTalkExcept ion as f a i l u r e :p r i n t u” D i s a s t e r ! {}” . format ( f a i l u r e )

e l s e :p r i n t u”OK! {}” . format ( o p i n i o n )

Page 23: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Urwid

I D-Bus integration

I good widgets set

I customization

I lot of nice stuff (resizing, keys, etc)

I it just works !

Page 24: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def
Page 25: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Pyjamas

I Python −→ JavaScript transpiler

I very active at the time

I a GWT port

I handle browsers incompatibilitiesI main advantages for us :

I factorizationI no context switch

Page 26: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Pyjamas

but. . .

I it’s nearly Python, but it’s not Python

I heavy and ugly pages (code)

I difficult to debug

I no luck to move to Python 3

I project hijacked

I and now dead

Page 27: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Outline

Some words about the projecta lot of featuresother interfaces

about the technologiesglobal architecture

Python !about the choice of Pythonsome advantages

Twisted

Urwid

PyjamasA New Hope

Things we have learnedSalut a Vous

Page 28: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

A New Hope

Brython

I not a compiler, an interpreter

I Python 3

I Python test suite

I active

I debugger

I stay close to HTML

Page 29: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

A New Hope

Brython

I not a compiler, an interpreter

I Python 3

I Python test suite

I active

I debugger

I stay close to HTML

Page 30: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Things we have learned

I stay focused

I new technologies can wait

I look for the community

I and the stability

Page 31: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Outline

Some words about the projecta lot of featuresother interfaces

about the technologiesglobal architecture

Python !about the choice of Pythonsome advantages

Twisted

Urwid

PyjamasA New Hope

Things we have learnedSalut a Vous

Page 32: Using Python and XMPP to build a decentralized social network...Twisted I asynchronous I huge framework I well thought abstractions I test driven development. Twisted I Deferred def

Thanks for your attention

I http://salut-a-toi.org (official website)

I https://www.libervia.org (demo)

I [email protected] (courriel)

I [email protected] (jid)

or meet me in Prague !