Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to python script #240

Merged
merged 12 commits into from
Jul 23, 2017
Merged

Conversation

hungrywolf27
Copy link
Contributor

Closes #239.

This makes the code more repetitive, but the dryrun should be as close as possible to the real thing, and should include checking original files.
Use 'default' option in argparse
Don't use argparse's type=open
Process header and footer inside main() function
Print header and footer before asking for confirmation
Header or footer may not be present if rmlint was run with no_header or no_footer
Show progress indicator
Print item message before exec_operation, not after
python script must be run as root for chown operations.
Accordingly, target uid and gid must be given by user on command line,
since they are not included in json output.
Add 100% Done at end
Use same colors as shell script
@sahib
Copy link
Owner

sahib commented Jun 26, 2017

Hello again. Thanks for that PR. I will try to review until the end of this week.

print('\nPlease hit any key before continuing to shredder your data.', file=sys.stderr)
sys.stdin.read(1)

print('# This is a dry run. Nothing will be modified.')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a colored # for this one too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

print('\nPlease hit any key before continuing to shredder your data.', file=sys.stderr)
sys.stdin.read(1)

print('# This is a dry run. Nothing will be modified.')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be printed if we're doing a dry_run...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that, it's fixed!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

'reset': "\x1b[0m" if USE_COLOR else "",
'green': "\x1b[32;01m" if USE_COLOR else "",
'blue': "\x1b[34;01m" if USE_COLOR else ""
}

Copy link
Owner

@sahib sahib Jul 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original_check needs to be adjusted to work with duplicated directories (i.e. call rmlint --equal for them).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't attempted this since it would require knowing the path to rmlint, which isn't included in the json output. As you commented below, it isn't necessary for the python script to support every feature of the sh output, at least for now.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but imho this is needed for correctness, not just as feature. But no blocker for this PR, I can implement that myself.

@sahib
Copy link
Owner

sahib commented Jul 2, 2017

I didn't have that much time to check, but I had a quick over it. Overall it looks good, but some places

There also some issues on my desk:

  • There is a bug that currently prevents using something like this: # rmlint -O py:/tmp.x.py.
    (No default outputs are created, other than what -O docs say).
  • % in the python output are duplicated due to the usage of fprintf. This leads to the double %%
    in the progress output.
  • Tests need to be adjusted. Especially some test that assert that the script works for both Py2 and Py3.x.
  • Code should be run through pylint to make it a bit more consistent.

Just a note: The original idea was to output an easily modifiable python script that can be adjusted to ones need. So I'm not necessarily for supporting every case and for exactly reproducing the functionality of the sh output (although I really approve the more familiar output you've added in this PR).

@sahib sahib merged commit 255f79e into sahib:develop Jul 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants