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. |
|
|
No blank line here. |
|
|
For this and every other option, one parameter per line. |
|
|
Think I'd prefer this just be --caption |
|
|
Think I'd rather we just fix that function then. We shouldn't pollute this file. Instead of doing options.foo, you can … |
|
|
Curious, maybe this is just something I'm not aware of with the new command infrastructure, but why aren't these just … |
|
|
Always treat these like proper sentences. It's missing a period. |
|
|
Trim the spaces. |
|
|
I agree. Let's do that. |
|
|
Pretty sure this fits on one line. |
|
|
Indentation is off. |
|
|
Things like this should be removed. |
|
|
The code's pretty self-explanatory. No need for the comment. |
|
|
Please use %s. This helps us localize. |
|
|
Maybe say what the default is. |
|
|
I can't imagine this looking right. Please properly terminate a string when you need to wrap and start it up … |
|
|
Alignment is off. |
|
|
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. |
|
|
Always should be proper sentences. Terminate with a period. |
|
|
Are these needed? |
|
|
Same comments as your diff change. Can you go through those and apply those same changes to this function? That … |
|
|
Do we not want to use die()? |
|
|
Surely there may be errors. We need to check the status and report them. |
|
|
Alphabetical. |
|
|
I think I'd prefer: request = self.root_resource \ .get_review_requests() \ .get_item(request_id) |
|
|
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? |
|
|
Indented too much |
|
-
-
-
-
rbtools/commands/rbattach.py (Diff revision 1) For this and every other option, one parameter per line.
-
-
rbtools/commands/rbattach.py (Diff revision 1) 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).
-
rbtools/commands/rbattach.py (Diff revision 1) 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?
-
rbtools/commands/rbattach.py (Diff revision 1) Always treat these like proper sentences. It's missing a period.
-
-
-
-
rbtools/commands/rbattach.py (Diff revision 1) 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.
-
-
-
rbtools/commands/rbattach.py (Diff revision 1) The code's pretty self-explanatory. No need for the comment.
-
-
-
rbtools/commands/rbattach.py (Diff revision 1) 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) |
---|
-
-
-
rbtools/commands/rbattach.py (Diff revision 3) 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)
-
Change Summary:
rebased on rb-general
Testing Done: |
|
||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+115) |
Change Summary:
Rebased on using the gettatr(options, field, default method for ALL
Diff: |
Revision 6 (+82) |
---|
-
-
-
rbtools/commands/rbattach.py (Diff revision 6) Always should be proper sentences. Terminate with a period.
-
-
rbtools/commands/rbattach.py (Diff revision 6) Same comments as your diff change. Can you go through those and apply those same changes to this function? That includes sys.exit. Kind of leaning toward moving this function into Client.
-
-
rbtools/commands/rbattach.py (Diff revision 6) Surely there may be errors. We need to check the status and report them.
-
Change Summary:
Rebased on using the gettatr(options, field, default method for ALL
Diff: |
Revision 7 (+76) |
---|
-
-
rbtools/commands/rbattach.py (Diff revision 7) I think I'd prefer: request = self.root_resource \ .get_review_requests() \ .get_item(request_id)
-
rbtools/commands/rbattach.py (Diff revision 7) I *think* this: request.get_file_attachments() \ .upload_attachment(filename, content, self.options.caption) Does PEP8 like that?
-
-
-
rbtools/commands/rbattach.py (Diff revision 7) 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: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|