Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ronny Eichler
dataman
Commits
d0616bb8
Commit
d0616bb8
authored
Mar 15, 2017
by
Ronny Eichler
Browse files
Absolute path handling
parent
377b1d4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
dataman/dataman.py
View file @
d0616bb8
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
__future__
import
print_function
import
sys
import
cmd
import
logging
import
argparse
import
os.path
as
op
from
.lib.constants
import
LOG_LEVEL_VERBOSE
...
...
@@ -32,7 +32,9 @@ class DataMan(cmd.Cmd):
parser
.
add_argument
(
'path'
,
help
=
'Relative or absolute path to directory'
,
default
=
'.'
,
nargs
=
'?'
)
cli_args
=
parser
.
parse_args
(
line
.
split
(
' '
)
if
line
else
''
)
path
=
cli_args
.
path
self
.
log
.
debug
(
'ls with args: {}'
.
format
(
cli_args
))
path
=
op
.
abspath
(
op
.
expanduser
(
cli_args
.
path
))
self
.
log
.
debug
(
'Expanded path: {}'
.
format
(
path
))
import
dataman.lib.dirstats
as
ds
ds
.
print_table
(
ds
.
gather
(
path
))
...
...
@@ -42,7 +44,9 @@ class DataMan(cmd.Cmd):
parser
.
add_argument
(
'path'
,
help
=
'Relative or absolute path to directory'
,
default
=
'.'
,
nargs
=
'?'
)
cli_args
=
parser
.
parse_args
(
line
.
split
(
' '
)
if
line
else
''
)
path
=
cli_args
.
path
self
.
log
.
debug
(
'Stats with args: {}'
.
format
(
cli_args
))
path
=
op
.
abspath
(
op
.
expanduser
(
cli_args
.
path
))
self
.
log
.
debug
(
'Expanded path: {}'
.
format
(
path
))
import
dataman.lib.dirstats
as
ds
ds
.
print_table
(
ds
.
gather
(
path
))
...
...
@@ -100,13 +104,14 @@ def main():
log_level
=
LOG_LEVEL_VERBOSE
if
cli_args
.
debug
else
LOG_LEVEL
logging
.
basicConfig
(
level
=
log_level
,
format
=
'%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
log
=
logging
.
getLogger
(
__name__
)
log
ger
=
logging
.
getLogger
(
__name__
)
log
.
debug
(
'CLI_ARGS: {}'
.
format
(
cli_args
))
log
.
debug
(
'CMD_ARGS: {}'
.
format
(
cmd_args
))
log
ger
.
debug
(
'CLI_ARGS: {}'
.
format
(
cli_args
))
log
ger
.
debug
(
'CMD_ARGS: {}'
.
format
(
cmd_args
))
# start cli
if
cli_args
.
command
in
[
None
,
'cli'
]:
logger
.
debug
(
'Starting CLI via command: {}'
.
format
(
cli_args
.
command
))
try
:
DataMan
().
cmdloop
()
except
KeyboardInterrupt
:
...
...
@@ -114,7 +119,7 @@ def main():
# some other command was given
else
:
print
(
'{}
{:}'
.
format
(
cli_args
.
command
,
' '
.
join
(
cmd_args
)))
logger
.
debug
(
'Command {}, args:
{:}'
.
format
(
cli_args
.
command
,
' '
.
join
(
cmd_args
)))
DataMan
().
onecmd
(
'{} {}'
.
format
(
cli_args
.
command
,
' '
.
join
(
cmd_args
)))
...
...
Write
Preview
Supports
Markdown
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