Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
su
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dmeiss2s
su
Commits
3c61aab7
Commit
3c61aab7
authored
9 years ago
by
Daniel Meißner
Committed by
Daniel Meißner
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
dependencies: added connected rf hardware check
parent
550a40fd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/dependencies.py
+33
-3
33 additions, 3 deletions
lib/dependencies.py
su.py
+4
-7
4 additions, 7 deletions
su.py
with
37 additions
and
10 deletions
lib/dependencies.py
+
33
−
3
View file @
3c61aab7
# -*- coding: utf-8 -*-
import
sys
import
os
from
hardware
import
Hardware
def
check_dependencies
():
"""
Check for needed external dependencies.
"""
print
(
"
Check dependencies…
"
)
print
(
"
… checked.
"
)
check_os
()
check_user
()
check_connected_hardware
()
print
(
"
… checked.
\n
"
)
def
check_user
():
"""
Check for running user. SU should not be run as root.
"""
if
os
.
getuid
()
==
0
:
print
(
"
Do not run %s as root
"
%
__file__
)
print
(
"
Do not run SU as root
"
)
sys
.
exit
()
else
:
print
(
"
* user id %s
"
%
os
.
getuid
())
def
check_os
():
"""
We do not support Windows
"""
if
os
.
name
!=
"
posix
"
:
print
(
"
Only Linux is supported at the moment!
"
)
sys
.
exit
()
else
:
print
(
"
* posix system
"
)
def
check_connected_hardware
():
"""
Output connected and supported rf hardware.
"""
devices
=
Hardware
().
get_connected_supported_devices
()
if
len
(
devices
)
==
0
:
print
(
"
* no rf hardware connected
"
)
else
:
print
(
"
* connected rf hardware:
"
)
for
device
in
devices
:
print
(
"
- %s (%s)
"
%
(
device
[
'
name
'
],
device
[
'
id
'
]))
This diff is collapsed.
Click to expand it.
su.py
+
4
−
7
View file @
3c61aab7
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
# stdlib
import
logging
import
sys
import
argparse
import
os
from
lib.version
import
__version__
from
PyQt5
import
QtCore
,
QtGui
,
QtWidgets
import
lib.dependencies
as
dep
import
lib.gui.gui
as
gui
from
PyQt5
import
QtCore
,
QtGui
,
QtWidgets
from
lib.version
import
__version__
from
lib.dependencies
import
check_dependencies
class
Su
(
object
):
"""
...
...
@@ -41,12 +40,10 @@ def parse_arguments():
return
parser
.
parse_args
()
def
main
():
args
=
parse_arguments
()
dep
.
check_user
()
dep
.
check_dependencies
()
check_dependencies
()
if
args
.
verbose
:
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment