Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
slapos.core
Commits
c99ccd2a
Commit
c99ccd2a
authored
Aug 15, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli: compatibility patches for cygwin (locale setting, check for root, --console parameter)
parent
cd2f9ebc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
slapos/cli/command.py
slapos/cli/command.py
+1
-1
slapos/cli/entry.py
slapos/cli/entry.py
+24
-0
slapos/cli/format.py
slapos/cli/format.py
+2
-0
No files found.
slapos/cli/command.py
View file @
c99ccd2a
...
...
@@ -23,7 +23,7 @@ class Command(cliff.command.Command):
def
must_be_root
(
func
):
@
functools
.
wraps
(
func
)
def
inner
(
self
,
*
args
,
**
kw
):
if
os
.
getuid
()
!=
0
:
if
sys
.
platform
!=
'cygwin'
and
os
.
getuid
()
!=
0
:
self
.
app
.
log
.
error
(
'This slapos command must be run as root.'
)
sys
.
exit
(
5
)
return
func
(
self
,
*
args
,
**
kw
)
...
...
slapos/cli/entry.py
View file @
c99ccd2a
...
...
@@ -114,6 +114,30 @@ class SlapOSApp(cliff.app.App):
command_manager
=
SlapOSCommandManager
(
'slapos.cli'
),
)
def
_set_streams
(
self
,
stdin
,
stdout
,
stderr
):
try
:
# SlapOS: might fail in some systems
locale
.
setlocale
(
locale
.
LC_ALL
,
''
)
except
locale
.
Error
:
pass
if
sys
.
version_info
[:
2
]
==
(
2
,
6
):
# Configure the input and output streams. If a stream is
# provided, it must be configured correctly by the
# caller. If not, make sure the versions of the standard
# streams used by default are wrapped with encodings. This
# works around a problem with Python 2.6 fixed in 2.7 and
# later (http://hg.python.org/cpython/rev/e60ef17561dc/).
lang
,
encoding
=
locale
.
getdefaultlocale
()
encoding
=
getattr
(
sys
.
stdout
,
'encoding'
,
None
)
or
encoding
self
.
stdin
=
stdin
or
codecs
.
getreader
(
encoding
)(
sys
.
stdin
)
self
.
stdout
=
stdout
or
codecs
.
getwriter
(
encoding
)(
sys
.
stdout
)
self
.
stderr
=
stderr
or
codecs
.
getwriter
(
encoding
)(
sys
.
stderr
)
else
:
self
.
stdin
=
stdin
or
sys
.
stdin
self
.
stdout
=
stdout
or
sys
.
stdout
self
.
stderr
=
stderr
or
sys
.
stderr
def
build_option_parser
(
self
,
*
args
,
**
kw
):
kw
.
setdefault
(
'argparse_kwargs'
,
{})
kw
[
'argparse_kwargs'
][
'conflict_handler'
]
=
'resolve'
...
...
slapos/cli/format.py
View file @
c99ccd2a
...
...
@@ -57,6 +57,8 @@ class FormatCommand(ConfigCommand):
help
=
"Don't actually do anything"
" (default: %(default)s)"
)
ap
.
add_argument
(
'-c'
,
'--console'
,
help
=
"Console output (obsolete)"
)
return
ap
@
must_be_root
...
...
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