aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2015-11-16 20:45:07 +0100
committerDave Andreoli <dave@gurumeditation.it>2015-11-16 20:45:07 +0100
commiteaf31100891e631e5d9dd0a713003b6d70178650 (patch)
tree04fd95a407e696bbd3fb0434440d99d07785953d /examples
parentOpen the 1.17 development phase (diff)
downloadpython-efl-eaf31100891e631e5d9dd0a713003b6d70178650.tar.gz
A new ecore module: ecore_con
It's now super easy to perform various network task in a full efl fashion. Implemented "Lookup" for dns query and "Url" to perform http requests. "Server" will come soon. Comes with quite complete docs, examples and unit tests
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/ecore/con/lookup.py18
-rwxr-xr-xexamples/ecore/con/url.py31
2 files changed, 49 insertions, 0 deletions
diff --git a/examples/ecore/con/lookup.py b/examples/ecore/con/lookup.py
new file mode 100755
index 0000000..db71402
--- /dev/null
+++ b/examples/ecore/con/lookup.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+
+from efl import ecore
+from efl import ecore_con
+
+
+def on_complete(canonname, ip):
+ print('Lookup completed')
+ print('Canonname: %s' % canonname)
+ print('Ip: %s' % ip)
+
+ ecore.main_loop_quit()
+
+ecore_con.Lookup('example.com', on_complete)
+
+ecore.main_loop_begin()
diff --git a/examples/ecore/con/url.py b/examples/ecore/con/url.py
new file mode 100755
index 0000000..2757e6d
--- /dev/null
+++ b/examples/ecore/con/url.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+
+from efl import ecore
+from efl import ecore_con
+
+def on_data(event):
+ print("data: " + str(event.data))
+ # do something here with the received data
+
+def on_progress(event):
+ # print(event)
+ print("received %d on a total of %d bytes" % (
+ event.down_now, event.down_total))
+
+def on_complete(event):
+ # print(event)
+ print("http result: %d" % event.status)
+ print("Total received bytes: %d" % event.url.received_bytes)
+
+ u.delete() # don't forget to delete !!
+ ecore.main_loop_quit()
+
+u = ecore_con.Url('http://www.example.com', verbose=False)
+u.on_data_event_add(on_data)
+u.on_progress_event_add(on_progress)
+u.on_complete_event_add(on_complete)
+u.get()
+
+ecore.main_loop_begin()