Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-init
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-init
Commits
a268273f
Commit
a268273f
authored
Oct 25, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+argvs
parent
b818ff34
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
3 deletions
+26
-3
generate_default_network_interfaces.py
src/generate_default_network_interfaces.py
+26
-3
No files found.
src/generate_default_network_interfaces.py
View file @
a268273f
...
@@ -35,11 +35,23 @@ __license__ = "GPL-3.0+"
...
@@ -35,11 +35,23 @@ __license__ = "GPL-3.0+"
__maintainer__
=
"Oleg Dzhimiev"
__maintainer__
=
"Oleg Dzhimiev"
__email__
=
"oleg@elphel.com"
__email__
=
"oleg@elphel.com"
'''
Usage (command line):
~$ generate_default_network_interfaces.py <ipaddr> <netmask> <gateway>
Example:
~$ generate_default_network_interfaces.py 192.168.0.9 255.255.255.0 192.168.0.15
'''
import
os
import
os
import
sys
path
=
"generated"
path
=
"generated"
filepath
=
os
.
path
.
join
(
path
,
"interfaces"
)
filepath
=
os
.
path
.
join
(
path
,
"interfaces"
)
ip
=
"192.168.0.9"
mask
=
"255.255.255.0"
gateway
=
"192.168.0.15"
# in python 3 it's a single line:
# in python 3 it's a single line:
# os.makedirs(path, exist_ok=True)
# os.makedirs(path, exist_ok=True)
try
:
try
:
...
@@ -48,9 +60,20 @@ except OSError:
...
@@ -48,9 +60,20 @@ except OSError:
if
not
os
.
path
.
isdir
(
path
):
if
not
os
.
path
.
isdir
(
path
):
raise
raise
ip
=
"192.168.0.9"
try
:
mask
=
"255.255.255.0"
ip
=
sys
.
argv
[
1
]
gateway
=
"192.168.0.15"
except
:
pass
try
:
mask
=
sys
.
argv
[
2
]
except
:
pass
try
:
gateway
=
sys
.
argv
[
3
]
except
:
pass
with
open
(
filepath
,
"w"
)
as
f
:
with
open
(
filepath
,
"w"
)
as
f
:
f
.
write
(
"""
\
f
.
write
(
"""
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment