[Python-modules-commits] [ripe-atlas-sagan] 01/04: Import ripe-atlas-sagan_1.1.11.orig.tar.gz

Apollon Oikonomopoulos apoikos at moszumanska.debian.org
Sun Sep 11 18:50:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

apoikos pushed a commit to branch master
in repository ripe-atlas-sagan.

commit 36182e186064d7c16e7eff7e4bc4311b0d8c36e0
Author: Apollon Oikonomopoulos <apoikos at debian.org>
Date:   Sun Sep 11 21:45:17 2016 +0300

    Import ripe-atlas-sagan_1.1.11.orig.tar.gz
---
 CHANGES.rst                 |  2 +
 ripe/atlas/sagan/base.py    |  5 +++
 ripe/atlas/sagan/version.py |  2 +-
 ripe/atlas/sagan/wifi.py    | 53 +++++++++++++++++++++++++
 tests/__init__.py           |  1 +
 tests/dns.py                |  2 +-
 tests/http.py               |  2 +-
 tests/ntp.py                |  2 +-
 tests/ping.py               |  2 +-
 tests/ssl.py                |  2 +-
 tests/traceroute.py         |  2 +-
 tests/wifi.py               | 97 +++++++++++++++++++++++++++++++++++++++++++++
 12 files changed, 165 insertions(+), 7 deletions(-)

diff --git a/CHANGES.rst b/CHANGES.rst
index 942d843..5a3db87 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,5 +1,7 @@
 Changelog
 =========
+* 1.1.11
+    * Added first version of WiFi results    
 * 1.1.10
     * Added a `parse_all_hops` kwarg to the Traceroute class to tell Sagan to stop parsing Hops and Packets once we have all of the last hop statistics (default=True)
     * Remove dependency on IPy: we were using it for IPv6 canonicalization, but all IPv6 addresses in results should be in canonical form to start with.
diff --git a/ripe/atlas/sagan/base.py b/ripe/atlas/sagan/base.py
index cb141ef..a13cbf9 100644
--- a/ripe/atlas/sagan/base.py
+++ b/ripe/atlas/sagan/base.py
@@ -189,6 +189,8 @@ class Result(ParsingDict):
         self.firmware = self.ensure("fw", int)
         self.origin = self.ensure("from", str)
         self.seconds_since_sync = self.ensure("lts", int)
+        self.group_id = self.ensure("group_id", int)
+        self.bundle = self.ensure("bundle", int)
 
         # Handle the weird case where fw=0 and we don't know what to expect
         if self.firmware == 0:
@@ -252,6 +254,9 @@ class Result(ParsingDict):
         elif kind == "ntp":
             from .ntp import NtpResult
             return NtpResult(raw_data, **kwargs)
+        elif kind == "wifi":
+            from .wifi import WiFiResult
+            return WiFiResult(raw_data, **kwargs)
 
         raise ResultParseError("Unknown type value was found in the JSON input")
 
diff --git a/ripe/atlas/sagan/version.py b/ripe/atlas/sagan/version.py
index 2bcfe10..c9aefd6 100644
--- a/ripe/atlas/sagan/version.py
+++ b/ripe/atlas/sagan/version.py
@@ -13,4 +13,4 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-__version__ = "1.1.10"
+__version__ = "1.1.11"
diff --git a/ripe/atlas/sagan/wifi.py b/ripe/atlas/sagan/wifi.py
new file mode 100644
index 0000000..f73618e
--- /dev/null
+++ b/ripe/atlas/sagan/wifi.py
@@ -0,0 +1,53 @@
+# Copyright (c) 2016 RIPE NCC
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from .base import Result, ParsingDict
+
+
+class WPASupplicant(ParsingDict):
+
+    def __init__(self, data, **kwargs):
+
+        ParsingDict.__init__(self, **kwargs)
+
+        self.address = data.get("address")
+        self.bssid = data.get("bssid")
+        self.connect_time = data.get("connect-time")
+        self.group_cipher = data.get("group_cipher")
+        self.wpa_supplicant_id = data.get("id")
+        self.ip_address = data.get("ip_address")
+        self.key_management = data.get("key_mgmt")
+        self.mode = data.get("mode")
+        self.pairwise_cipher = data.get("pairwise_cipher")
+        self.ssid = data.get("ssid")
+        self.wpa_state = data.get("wpa_state")
+
+
+class WiFiResult(Result):
+    """
+    WiFi measurement result class
+    """
+
+    def __init__(self, data, **kwargs):
+
+        Result.__init__(self, data, **kwargs)
+
+        self.wpa_supplicant = WPASupplicant(
+            data["wpa_supplicant"], **kwargs
+        )
+
+__all__ = (
+    "WiFiResult",
+)
diff --git a/tests/__init__.py b/tests/__init__.py
index 90754cf..2c7da1e 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -19,3 +19,4 @@ from .dns import *
 from .ssl import *
 from .http import *
 from .ntp import *
+from .wifi import *
diff --git a/tests/dns.py b/tests/dns.py
index 7e6ecd7..cad72f6 100644
--- a/tests/dns.py
+++ b/tests/dns.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2015 RIPE NCC
+# Copyright (c) 2016 RIPE NCC
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/tests/http.py b/tests/http.py
index 44e657d..e6ab8f7 100644
--- a/tests/http.py
+++ b/tests/http.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2015 RIPE NCC
+# Copyright (c) 2016 RIPE NCC
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/tests/ntp.py b/tests/ntp.py
index 91c7ad4..794aad4 100644
--- a/tests/ntp.py
+++ b/tests/ntp.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2015 RIPE NCC
+# Copyright (c) 2016 RIPE NCC
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/tests/ping.py b/tests/ping.py
index 13d0e82..e4b8544 100644
--- a/tests/ping.py
+++ b/tests/ping.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2015 RIPE NCC
+# Copyright (c) 2016 RIPE NCC
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/tests/ssl.py b/tests/ssl.py
index 57b8dbb..38b76c7 100644
--- a/tests/ssl.py
+++ b/tests/ssl.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2015 RIPE NCC
+# Copyright (c) 2016 RIPE NCC
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/tests/traceroute.py b/tests/traceroute.py
index 16b2bf6..59f9f1b 100644
--- a/tests/traceroute.py
+++ b/tests/traceroute.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2015 RIPE NCC
+# Copyright (c) 2016 RIPE NCC
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/tests/wifi.py b/tests/wifi.py
new file mode 100644
index 0000000..cbdd2e0
--- /dev/null
+++ b/tests/wifi.py
@@ -0,0 +1,97 @@
+# Copyright (c) 2016 RIPE NCC
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from ripe.atlas.sagan import Result
+from ripe.atlas.sagan.wifi import WiFiResult
+
+
+def test_wifi():
+    raw_data = {
+        "bundle": 1463495978,
+        "from": "2001:67c:2e8:ffe1:eade:27ff:fe69:e6f0",
+        "fw": "4733",
+        "group_id": 1021275,
+        "msm_id": 1021275,
+        "msm_name": "WiFi",
+        "prb_id": 105,
+        "timestamp": 1463495978,
+        "type": "wifi",
+        "wpa_supplicant": {
+            "address": "ea:de:27:69:e6:f0",
+            "bssid": "08:ea:44:3b:6d:14",
+            "connect-time": "2",
+            "group_cipher": "CCMP",
+            "id": "0",
+            "ip_address": "193.0.10.126",
+            "key_mgmt": "WPA2-PSK",
+            "mode": "station",
+            "pairwise_cipher": "CCMP",
+            "ssid": "guestnet",
+            "wpa_state": "COMPLETED"
+        }
+    }
+
+    result = Result.get(raw_data)
+    assert(isinstance(result, WiFiResult))
+    assert(result.bundle == 1463495978)
+    assert(result.origin == "2001:67c:2e8:ffe1:eade:27ff:fe69:e6f0")
+    assert(result.firmware == 4733)
+    assert(result.group_id == 1021275)
+    assert(result.wpa_supplicant.address == "ea:de:27:69:e6:f0")
+    assert(result.wpa_supplicant.bssid == "08:ea:44:3b:6d:14")
+    assert(result.wpa_supplicant.connect_time == "2")
+    assert(result.wpa_supplicant.group_cipher == "CCMP")
+    assert(result.wpa_supplicant.wpa_supplicant_id == "0")
+    assert(result.wpa_supplicant.ip_address == "193.0.10.126")
+    assert(result.wpa_supplicant.key_management == "WPA2-PSK")
+    assert(result.wpa_supplicant.mode == "station")
+    assert(result.wpa_supplicant.pairwise_cipher == "CCMP")
+    assert(result.wpa_supplicant.ssid == "guestnet")
+    assert(result.wpa_supplicant.wpa_state == "COMPLETED")
+
+
+def test_wifi_error():
+    raw_data = {
+        "bundle": 1463493022,
+        "error": "wpa timeout",
+        "from": "2001:67c:2e8:ffe1:eade:27ff:fe69:e6f0",
+        "fw": "4733",
+        "group_id": 1021275,
+        "msm_id": 1021275,
+        "msm_name": "WiFi",
+        "prb_id": 105,
+        "timestamp": 1463493023,
+        "type": "wifi",
+        "wpa_supplicant": {"connect-time": "11"}
+    }
+
+    result = Result.get(raw_data)
+    assert(isinstance(result, WiFiResult))
+    assert(result.bundle == 1463493022)
+    assert(result.origin == "2001:67c:2e8:ffe1:eade:27ff:fe69:e6f0")
+    assert(result.firmware == 4733)
+    assert(result.group_id == 1021275)
+    assert(result.created_timestamp == 1463493023)
+    assert(result.wpa_supplicant.address is None)
+    assert(result.wpa_supplicant.bssid is None)
+    assert(result.wpa_supplicant.connect_time == "11")
+    assert(result.wpa_supplicant.group_cipher is None)
+    assert(result.wpa_supplicant.wpa_supplicant_id is None)
+    assert(result.wpa_supplicant.ip_address is None)
+    assert(result.wpa_supplicant.key_management is None)
+    assert(result.wpa_supplicant.mode is None)
+    assert(result.wpa_supplicant.pairwise_cipher is None)
+    assert(result.wpa_supplicant.ssid is None)
+    assert(result.wpa_supplicant.wpa_state is None)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/ripe-atlas-sagan.git



More information about the Python-modules-commits mailing list