RB Attach
Review Request #3599 — Created Dec. 1, 2012 and submitted
A command that allows the user to attach a file to a specific review request. Args: rb attach <request_id> <path/to/file> Options: --description (caption), --filename (custom filename)
Tried the following on dev server, all of which were successful: rb attach <request_id> <path/to/file> rb attach <request_id> <path/to/file> --description='some desc' rb attach <request_id> <path/to/file> --filename='custom filename' rb attach <request_id> <path/to/file> --description='some desc' --filename='custom filename' rb attach <invalid_request_id> rb patch <invalid_request_id> <invalid/path/to/file> rb attach <invalid/path/to/file> Retested with rb-general (removal of extra options)
Description | From | Last Updated |
---|---|---|
Make sure these are alphabetical. |
chipx86 | |
No blank line here. |
chipx86 | |
For this and every other option, one parameter per line. |
chipx86 | |
Think I'd prefer this just be --caption |
chipx86 | |
Think I'd rather we just fix that function then. We shouldn't pollute this file. Instead of doing options.foo, you can … |
chipx86 | |
Curious, maybe this is just something I'm not aware of with the new command infrastructure, but why aren't these just … |
chipx86 | |
Always treat these like proper sentences. It's missing a period. |
chipx86 | |
Trim the spaces. |
chipx86 | |
I agree. Let's do that. |
chipx86 | |
Pretty sure this fits on one line. |
chipx86 | |
Indentation is off. |
chipx86 | |
Things like this should be removed. |
chipx86 | |
The code's pretty self-explanatory. No need for the comment. |
chipx86 | |
Please use %s. This helps us localize. |
chipx86 | |
Maybe say what the default is. |
chipx86 | |
I can't imagine this looking right. Please properly terminate a string when you need to wrap and start it up … |
chipx86 | |
Alignment is off. |
chipx86 | |
These should be alphabetical |
SL slchen | |
You can probably condense: file_attachments = request.get_file_attachments() ... file_attachments.upload_attachment(filename, content, self.options.caption) To just: request.get_file_attachments().upload_attachment(filename, content, self.options.caption) |
SL slchen | |
Should the the error be logged? |
SL slchen | |
Two blank lines. |
chipx86 | |
Always should be proper sentences. Terminate with a period. |
chipx86 | |
Are these needed? |
chipx86 | |
Same comments as your diff change. Can you go through those and apply those same changes to this function? That … |
chipx86 | |
Do we not want to use die()? |
chipx86 | |
Surely there may be errors. We need to check the status and report them. |
chipx86 | |
Alphabetical. |
chipx86 | |
I think I'd prefer: request = self.root_resource \ .get_review_requests() \ .get_item(request_id) |
mike_conley | |
I think you can do this with a Python "with" structure since RB 1.7 is moving to Python 2.5+; The … |
SL slchen | |
I *think* this: request.get_file_attachments() \ .upload_attachment(filename, content, self.options.caption) Does PEP8 like that? |
mike_conley | |
Indented too much |
mike_conley |
-
-
-
-
-
-
Think I'd rather we just fix that function then. We shouldn't pollute this file. Instead of doing options.foo, you can in those cases do getattr(options, 'foo', somedefault).
-
Curious, maybe this is just something I'm not aware of with the new command infrastructure, but why aren't these just provided as defaults when declaring the options above?
-
-
-
-
-
You're right, we should figure this out. Either in the base class or some utility function somewhere. I'd get smacleod's opinion on this too.
-
-
-
-
-
-
I can't imagine this looking right. Please properly terminate a string when you need to wrap and start it up again explicitly on the next line. I'd also change the text to: "Uploaded %s to review request %s."
-
- Change Summary:
-
- refactored according to the changes in base commadnd - pep8 style fixes
- Diff:
-
Revision 2 (+115)
- Change Summary:
-
Changed the way commands are branched from other features (rb-general). Ex.: http://pastie.org/5468764
- Diff:
-
Revision 3 (+115)
- Change Summary:
-
rebased on rb-general
- Testing Done:
-
Tried the following on dev server, all of which were successful:
rb patch <request_id> <path/to/file>
rb patch <request_id> <path/to/file> --description='some desc' rb patch <request_id> <path/to/file> --filename='custom filename' rb patch <request_id> <path/to/file> --description='some desc' --filename='custom filename' rb patch <invalid_request_id>
rb patch <invalid_request_id> <invalid/path/to/file> rb patch <invalid/path/to/file> + + Retested with rb-general (removal of extra options)
- Diff:
-
Revision 4 (+115)
-
-
I think you can do this with a Python "with" structure since RB 1.7 is moving to Python 2.5+; The key advantage is guaranteed file closure afterwards, no matter what happens. Something like the following: try: with open(path_to_file, 'r') as opened_file: content = opened_file.read() except IOError: die("%s is not a valid file." % (path_to_file)) And the file closure is done for you.
-
Your change description seems... odd. Your summary and diff is "RB Attach" but the description talks about "rb patch"
- Change Summary:
-
patch --> attach
- Description:
-
A command that allows the user to attach a file to a specific review request.
~ Args: rb patch <request_id> <path/to/file>
~ Args: rb attach <request_id> <path/to/file>
Options: --description (caption), --filename (custom filename) - Testing Done:
-
Tried the following on dev server, all of which were successful:
~ rb patch <request_id> <path/to/file>
~ rb patch <request_id> <path/to/file> --description='some desc' ~ rb patch <request_id> <path/to/file> --filename='custom filename' ~ rb patch <request_id> <path/to/file> --description='some desc' --filename='custom filename' ~ rb attach <request_id> <path/to/file>
~ rb attach <request_id> <path/to/file> --description='some desc' ~ rb attach <request_id> <path/to/file> --filename='custom filename' ~ rb attach <request_id> <path/to/file> --description='some desc' --filename='custom filename' ~ rb patch <invalid_request_id>
~ rb attach <invalid_request_id>
rb patch <invalid_request_id> <invalid/path/to/file> ~ rb patch <invalid/path/to/file> ~ rb attach <invalid/path/to/file> Retested with rb-general (removal of extra options)