Skip to content

Commit

Permalink
Merge pull request #46 from Sanji-IO/develop
Browse files Browse the repository at this point in the history
Release ThingsPro_V2.0
  • Loading branch information
imZack authored Apr 17, 2017
2 parents f6094d2 + 55aea6d commit 3f1a1ed
Show file tree
Hide file tree
Showing 12 changed files with 535 additions and 262 deletions.
2 changes: 1 addition & 1 deletion build-deb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extract-upstream:
tar zxf $(UPSTREAM_ORIG_ARCHIVE)

changelog:
dch -v $(VERSION)-$(DEBVERSION) -D $(DIST) -M -u low \
dch -v $(VERSION) -D $(DIST) -M -u low \
--release-heuristic log

clean:
Expand Down
37 changes: 37 additions & 0 deletions build-deb/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
sanji-bundle-route (1.2.0) unstable; urgency=low

* feat: Support `status` and `wan`.

-- Aeluin Chen <aeluin.chen@moxa.com> Wed, 05 Apr 2017 16:00:35 +0800

sanji-bundle-route (1.1.0) unstable; urgency=low

* feat: Get interface via shell script command.

-- Aeluin Chen <aeluin.chen@moxa.com> Thu, 30 Mar 2017 19:18:05 +0800

sanji-bundle-route (1.0.3) unstable; urgency=low

* fix: Add "-pf" for `dhclient`.
* fix: Use "True/False" instead of "1/0".

-- Aeluin Chen <aeluin.chen@moxa.com> Thu, 09 Mar 2017 18:31:02 +0800

sanji-bundle-route (1.0.2) unstable; urgency=low

* Update pip deps.

-- Zack YL Shih <zackyl.shih@moxa.com> Thu, 20 Oct 2016 17:38:13 +0800

sanji-bundle-route (1.0.1) unstable; urgency=low

* Remove DNS PUT.

-- Aeluin Chen <aeluin.chen@moxa.com> Thu, 24 Mar 2016 17:44:02 +0800

sanji-bundle-route (1.0.0-1) unstable; urgency=low

* Update API schema.

-- Aeluin Chen <aeluin.chen@moxa.com> Wed, 02 Mar 2016 15:36:09 +0800

sanji-bundle-route (0.10.5-1) unstable; urgency=low

* Change dhcp client setting to non-blocking mode.
Expand Down
2 changes: 1 addition & 1 deletion build-deb/debian/source/format
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0 (quilt)
3.0 (native)
18 changes: 3 additions & 15 deletions bundle.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "route",
"version": "0.10.5",
"version": "1.2.0",
"author": "Aeluin Chen",
"email": "aeluin.chen@moxa.com",
"description": "Handle the routing table",
"description": "Handles the routing table",
"license": "MOXA",
"main": "route.py",
"argument": "",
Expand All @@ -17,19 +17,7 @@
"resources": [
{
"role": "view",
"resource": "/network/interface"
},
{
"role": "view",
"resource": "/network/dns"
},
{
"methods": ["get"],
"resource": "/network/routes/interfaces"
},
{
"methods": ["get","put"],
"resource": "/network/routes/db"
"resource": "/network/interfaces/:name"
},
{
"methods": ["get","put"],
Expand Down
4 changes: 1 addition & 3 deletions data/route.json.factory
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"default": "eth0"
}
["eth0"]
25 changes: 11 additions & 14 deletions ip/addr.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def ifaddresses(iface):
try:
info["link"] = open("/sys/class/net/%s/operstate" % iface).read()
if "down" == info["link"][:-1]:
info["link"] = 0
info["link"] = False
else:
info["link"] = open("/sys/class/net/%s/carrier" % iface).read()
info["link"] = int(info["link"][:-1]) # convert to int
info["link"] = True if int(info["link"][:-1]) == 1 else False
except:
info["link"] = 0
info["link"] = False

info["inet"] = []
if netifaces.AF_INET not in full:
Expand Down Expand Up @@ -118,25 +118,21 @@ def ifupdown(iface, up):


def dhclient(iface, enable, script=None):
# Disable the dhcp client and flush interface
# Enable/0Disable the dhcp client and flush interface
# dhclient -pf /var/run/dhclient-<iface>.pid <iface>
# dhclient -r -pf /var/run/dhclient-<iface>.pid <iface>
pid_file = "/var/run/dhclient-{}.pid".format(iface)
try:
dhclients = sh.awk(
sh.grep(
sh.grep(sh.ps("ax"), iface, _timeout=5),
"dhclient", _timeout=5),
"{print $1}")
dhclients = dhclients.split()
for dhclient in dhclients:
sh.kill(dhclient)
sh.dhclient("-r", "-pf", pid_file, iface)
except Exception as e:
_logger.info("Failed to stop dhclient: %s" % e)
pass

if enable:
if script:
sh.dhclient("-nw", "-sf", script, iface, _bg=True)
sh.dhclient("-pf", pid_file, "-nw", "-sf", script, iface)
else:
sh.dhclient("-nw", iface, _bg=True)
sh.dhclient("-pf", pid_file, "-nw", iface)


def ifconfig(iface, dhcpc, ip="", netmask="24", gateway="", script=None):
Expand Down Expand Up @@ -182,6 +178,7 @@ def ifconfig(iface, dhcpc, ip="", netmask="24", gateway="", script=None):
print interfaces()

# ifconfig("eth0", True)
# dhclient("eth0", False)
# time.sleep(10)
# ifconfig("eth1", False, "192.168.31.36")
eth0 = ifaddresses("eth0")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
paho-mqtt==1.1
paho-mqtt>=1.1
sh
ipcalc
netifaces
Expand Down
Loading

0 comments on commit 3f1a1ed

Please sign in to comment.