Skip to content

Commit

Permalink
Rework after code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Damian authored and Adrian Damian committed Jan 31, 2024
1 parent 2fa4b66 commit 9ba7bea
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 41 deletions.
4 changes: 2 additions & 2 deletions vos/vos/commands/vchmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ def vchmod():
successes, failures = client.update(node, opt.recursive)
if opt.recursive:
if failures:
sys.stderr.write('WARN. updated count: {}, failed count: {}\n'.
logging.error('WARN. updated count: {}, failed count: {}\n'.

Check warning on line 205 in vos/vos/commands/vchmod.py

View check run for this annotation

Codecov / codecov/patch

vos/vos/commands/vchmod.py#L202-L205

Added lines #L202 - L205 were not covered by tests
format(successes, failures))
sys.exit(-1)

Check warning on line 207 in vos/vos/commands/vchmod.py

View check run for this annotation

Codecov / codecov/patch

vos/vos/commands/vchmod.py#L207

Added line #L207 was not covered by tests
else:
sys.stdout.write('DONE. updated count: {}\n'.format(successes))
logging.info('DONE. updated count: {}\n'.format(successes))

Check warning on line 209 in vos/vos/commands/vchmod.py

View check run for this annotation

Codecov / codecov/patch

vos/vos/commands/vchmod.py#L209

Added line #L209 was not covered by tests
except Exception as ex:
exit_on_exception(ex)

Expand Down
6 changes: 3 additions & 3 deletions vos/vos/commands/vrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
def vrm():
parser = CommonParser(description=DESCRIPTION)
parser.add_argument(
"-r", "--recursive", action="store_true",
"-R", "--recursive", action="store_true",
help="Delete a file or directory even if it's not empty.",
default=False)
parser.add_argument('node',
Expand All @@ -106,11 +106,11 @@ def vrm():
if args.recursive:
successes, failures = client.recursive_delete(node)
if failures:
sys.stderr.write('WARN. deleted count: {}, failed count: '
logging.error('WARN. deleted count: {}, failed count: '

Check warning on line 109 in vos/vos/commands/vrm.py

View check run for this annotation

Codecov / codecov/patch

vos/vos/commands/vrm.py#L106-L109

Added lines #L106 - L109 were not covered by tests
'{}\n'.format(successes, failures))
sys.exit(-1)

Check warning on line 111 in vos/vos/commands/vrm.py

View check run for this annotation

Codecov / codecov/patch

vos/vos/commands/vrm.py#L111

Added line #L111 was not covered by tests
else:
sys.stdout.write(
logging.info(

Check warning on line 113 in vos/vos/commands/vrm.py

View check run for this annotation

Codecov / codecov/patch

vos/vos/commands/vrm.py#L113

Added line #L113 was not covered by tests
'DONE. deleted count: {}\n'.format(successes))
else:
if not node.endswith('/'):
Expand Down
16 changes: 8 additions & 8 deletions vos/vos/commands/vtag.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
The tag system is meant to allow tags, in addition to the standard node
properties. """
import logging
import pprint
import sys
from ..commonparser import CommonParser, set_logging_level_from_args, \
Expand Down Expand Up @@ -111,8 +112,7 @@ def vtag():
parser.add_option('-R', '--recursive', action="store_true",
help='perform the operation recursively on all the descendants')

opt = parser.parse_args()
args = opt
args = parser.parse_args()
set_logging_level_from_args(args)

# the node should be the first argument, the rest should contain
Expand All @@ -131,9 +131,9 @@ def vtag():

try:
client = vos.Client(
vospace_certfile=opt.certfile,
vospace_token=opt.token,
insecure=opt.insecure)
vospace_certfile=args.certfile,
vospace_token=args.token,
insecure=args.insecure)
node = client.get_node(node_arg)

Check warning on line 137 in vos/vos/commands/vtag.py

View check run for this annotation

Codecov / codecov/patch

vos/vos/commands/vtag.py#L137

Added line #L137 was not covered by tests
if len(props) == 0:
# print all properties
Expand All @@ -147,14 +147,14 @@ def vtag():
value = None
node.props[key] = value
successes, failures = client.add_props(node, recursive=True)
if opt.recursive:
if args.recursive:
if failures:
sys.stderr.write(
logging.error(

Check warning on line 152 in vos/vos/commands/vtag.py

View check run for this annotation

Codecov / codecov/patch

vos/vos/commands/vtag.py#L148-L152

Added lines #L148 - L152 were not covered by tests
'WARN. updated count: {}, failed count: {}\n'.
format(successes, failures))
sys.exit(-1)

Check warning on line 155 in vos/vos/commands/vtag.py

View check run for this annotation

Codecov / codecov/patch

vos/vos/commands/vtag.py#L155

Added line #L155 was not covered by tests
else:
sys.stdout.write(
logging.info(

Check warning on line 157 in vos/vos/commands/vtag.py

View check run for this annotation

Codecov / codecov/patch

vos/vos/commands/vtag.py#L157

Added line #L157 was not covered by tests
'DONE. updated count: {}\n'.format(successes))
else:
changed = False
Expand Down
28 changes: 0 additions & 28 deletions vos/vos/vos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2715,34 +2715,6 @@ def update(self, node, recursive=False):
+ response.status_code)
return self._run_recursive_job(session,
response.headers['location'])
# else:
# # TODO this is deprecated and should be removed soon
# try:
# property_url = endpoints.properties
# except KeyError as ex:
# logger.debug('Endpoint does not exist: {0}'.format(str(ex)))
# raise Exception('Operation not supported')
#
# logger.debug("prop URL: {0}".format(property_url))
# try:
# resp = session.post(
# property_url, allow_redirects=False, data=str(node),
# headers={'Content-type': 'text/xml'})
# except Exception as ex:
# logger.error(str(ex))
# raise ex
# if resp is None:
# raise OSError(errno.EFAULT, "Failed to connect VOSpace")
# logger.debug("Got prop-update response: {0}".format(resp.content))
# transfer_url = resp.headers.get('Location', None)
# logger.debug("Got job status redirect: {0}".format(transfer_url))
# # Start the job
# session.post(
# transfer_url + "/phase",
# allow_redirects=False,
# data="PHASE=RUN",
# headers={'Content-type': "application/x-www-form-urlencoded"})
# self.get_transfer_error(transfer_url, node.uri)
else:
resp = session.post(url, data=str(node), allow_redirects=False)
logger.debug("update response: {0}".format(resp.content))
Expand Down

0 comments on commit 9ba7bea

Please sign in to comment.