Print out warning when interrupt in prepare-dev.py after syncing database has started
Review Request #6845 — Created Jan. 31, 2015 and submitted
Problem:
- If the user runs prepare-dev.py and interrupts after the syncing database has started, they will end up with no super user when re-run the commmand. This is because the reviewboard.db is already existed.
Fix:
- The database reviewboard.db only created when site.sync_database is called. I put a try catch KeyBoardInterrupt around the whole if options.sync_db. After calling prepare-dev.py, if we interrupt before syncing database happens, the reviewboard.db hasn't created yet. If the user calls it again, the super user will be promted again. Therefore, we only need to put the try catch when the site.sync_database is called to prompt the user about rm reviewboard.db before re-run the command.
Manual test: Interrupt after Synchronizing database is called and checked that the warning is printed to commandline. If the interrupt happens before the database is created, no warning is printed which is expected.
Description | From | Last Updated |
---|---|---|
Col: 80 E501 line too long (94 > 79 characters) |
reviewbot | |
Col: 1 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 74 W291 trailing whitespace |
reviewbot | |
Col: 27 W604 backticks are deprecated, use 'repr()' |
reviewbot | |
Col: 51 E225 missing whitespace around operator |
reviewbot | |
Col: 54 E226 missing whitespace around arithmetic operator |
reviewbot | |
We are inconsistent all over the code base, but for all new strings we want to be using single quotes. … |
brennie | |
We probably don't want to print this out if there's an interrupt. Maybe move it inside the try after sync_database? |
david | |
Can you remove the extra blank line you added here? We generally keep 2 blank lines between top-level functions. |
anselina | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
"preparing process" sounds a little awkward. How about, "development preparation process" |
mike_conley | |
"create super user" -> "create a super user" |
mike_conley | |
/src/reviewboard isn't necessarily correct - that's probably only true if the developer is using vagrant. We can probably dynamically figure … |
mike_conley | |
Col: 80 E501 line too long (86 > 79 characters) |
reviewbot | |
Col: 68 E231 missing whitespace after ',' |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Undo this change. |
brennie | |
Instead of doing this, you can import reviewboard and use reviewboard.__file__ |
brennie | |
'reviewboard' imported but unused |
reviewbot | |
'realpath' imported but unused |
reviewbot | |
'reviewboard' imported but unused |
reviewbot | |
This should go in another import group because it is from the reviewboard package. |
brennie | |
You should use os.path.dirname(reviewboard.__file__) instead of joining '..' twice. Your code makes it seem as if you are moving up … |
brennie | |
Add a blank line between these two. |
david | |
'reviewboard' imported but unused |
reviewbot | |
It might be nice to align everything to 4 space boundaries: warnings.warn( 'The development preparation process exited before completing. In … |
david | |
'reviewboard' imported but unused |
reviewbot | |
Something to note here.. Exiting at any point during the syncdb may do more than fail to create a superuser. … |
chipx86 | |
'reviewboard' imported but unused |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
'reviewboard' imported but unused |
reviewbot |
- Commit:
-
ab76a8672d1dcb0bdb3ee773836dae1452c1319ab0290fbf447714e8f37ce2ed23b29f0040d0c69a
- Diff:
-
Revision 2 (+8 -1)
- Commit:
-
b0290fbf447714e8f37ce2ed23b29f0040d0c69a6629785c2da3d27aefe00fe5bfc10f44f9dcb259
- Diff:
-
Revision 3 (+8 -1)
-
Tool: Pyflakes Processed Files: contrib/internal/prepare-dev.py Tool: PEP8 Style Checker Processed Files: contrib/internal/prepare-dev.py
- Description:
-
~ Issue-3714: print out warning when interrupt
~ Issue-3714: Print out warning when interrupt. The database reviewboard.db only created when site.sync_database is called. I put a try catch KeyBoardInterrupt around this to print out the warning.
- Testing Done:
-
- The database reviewboard.db only created when site.sync_database is called. I put a try catch KeyBoardInterrupt around this to print out the warning.
- Manual test: Interrupt after Synchronizing database is called and checked that the warning is printed to commandline. If the interrupt happens before the database is created, no warning is printed which is expected.
-
You don't need to mention the issue number in the title and the summary. Since its in the
bugs
field, it will automatically be added to the commit message. when it gets landed. -
We are inconsistent all over the code base, but for all new strings we want to be using single quotes.
Also, for user-visible strings we want to use "" instead of Markdown back-ticks.
- Summary:
-
Issue-3714: print out warning when interruptPrint out warning when interrupt
- Description:
-
~ Issue-3714: Print out warning when interrupt. The database reviewboard.db only created when site.sync_database is called. I put a try catch KeyBoardInterrupt around this to print out the warning.
~ Print out warning when interrupt. The database reviewboard.db only created when site.sync_database is called. I put a try catch KeyBoardInterrupt around this to print out the warning.
- Description:
-
~ Print out warning when interrupt. The database reviewboard.db only created when site.sync_database is called. I put a try catch KeyBoardInterrupt around this to print out the warning.
~ Print out warning when interrupt. The database reviewboard.db only created when site.sync_database is called. I put a try catch KeyBoardInterrupt around this to print out the warning.
+ After calling prepare-dev.py, if we interrupt before syncing database happens, the reviewboard.db hasn't created yet. If the user calls it again, the super user will be promted again. Therefore, we only need to put the try catch when the site.sync_database is called to prompt the user about rm reviewboard.db before re-run the command.
-
Tool: PEP8 Style Checker Processed Files: contrib/internal/prepare-dev.py Tool: Pyflakes Processed Files: contrib/internal/prepare-dev.py
- Summary:
-
Print out warning when interruptPrint out warning when interrupt in prepare-dev.py after syncing database has started
- Description:
-
~ Print out warning when interrupt. The database reviewboard.db only created when site.sync_database is called. I put a try catch KeyBoardInterrupt around this to print out the warning.
~ After calling prepare-dev.py, if we interrupt before syncing database happens, the reviewboard.db hasn't created yet. If the user calls it again, the super user will be promted again. Therefore, we only need to put the try catch when the site.sync_database is called to prompt the user about rm reviewboard.db before re-run the command. ~ Problem:
~ - If the user runs prepare-dev.py and interrupts after the syncing database has started, they will end up with no super user when re-run the commmand. This is because the reviewboard.db is already existed. + Fix: + - The database reviewboard.db only created when site.sync_database is called. I put a try catch KeyBoardInterrupt around the whole if options.sync_db. After calling prepare-dev.py, if we interrupt before syncing database happens, the reviewboard.db hasn't created yet. If the user calls it again, the super user will be promted again. Therefore, we only need to put the try catch when the site.sync_database is called to prompt the user about rm reviewboard.db before re-run the command. - Commit:
-
fd04c35d78223f4e2d4b9d85b4108eaaf633ab8c
- Diff:
-
Revision 5 (+16 -9)
- Commit:
-
fd04c35d78223f4e2d4b9d85b4108eaaf633ab8c026f57da79b3f731612f90f1152b0d620be2efff
- Diff:
-
Revision 6 (+15 -8)
-
Tool: Pyflakes Processed Files: contrib/internal/prepare-dev.py Tool: PEP8 Style Checker Processed Files: contrib/internal/prepare-dev.py
- Commit:
-
026f57da79b3f731612f90f1152b0d620be2efff98e94b45e5d784266fe1123e15124036ff5dac98
- Diff:
-
Revision 7 (+17 -9)
- Commit:
-
98e94b45e5d784266fe1123e15124036ff5dac98106e06bad1cecf22a50658f410dec0b10bbf67f2
- Diff:
-
Revision 8 (+18 -9)
- Commit:
-
106e06bad1cecf22a50658f410dec0b10bbf67f2211ce179634424706fd6f163fe6b43e2b8ec3ac1
- Diff:
-
Revision 9 (+19 -9)
-
Tool: PEP8 Style Checker Processed Files: contrib/internal/prepare-dev.py Tool: Pyflakes Processed Files: contrib/internal/prepare-dev.py
- Commit:
-
211ce179634424706fd6f163fe6b43e2b8ec3ac1005e8040d391cda64d80474c776d626e1690f25b
- Diff:
-
Revision 10 (+20 -8)
- Commit:
-
005e8040d391cda64d80474c776d626e1690f25b9a1a97e3a8ab98435e98d2f7a9bbdf25f1cabd8a
- Diff:
-
Revision 11 (+20 -8)
- Commit:
-
9a1a97e3a8ab98435e98d2f7a9bbdf25f1cabd8a53f251fb7d9645b0a2782259a6bd37dfad7da928
- Diff:
-
Revision 12 (+19 -8)
-
-
-
It might be nice to align everything to 4 space boundaries:
warnings.warn( 'The development preparation process exited before completing. In order ' 'to create a super user, you need to run "rm reviewboard.db" in %s and ' 'run prepare-dev.py again.' % os.path.abspath( os.path.join(os.path.dirname(reviewboard.__file__), '..')))
- Commit:
-
53f251fb7d9645b0a2782259a6bd37dfad7da928f9b7a449daa8b7e92f2f9f1210fd8b117b13745c
- Diff:
-
Revision 13 (+19 -8)
-
-
Something to note here.. Exiting at any point during the syncdb may do more than fail to create a superuser. It can actually leave the database in an inconsistent state.
I would change this error to instead say that the database may be in an inconsistent state and to remove the file and start over.
Also,
warnings.warn
is the wrong thing here. That's more for programattic warning involving something like a deprecated module or function being used. I would usesys.stderr.write(..)
instead.
- Commit:
-
f9b7a449daa8b7e92f2f9f1210fd8b117b13745c574147d9fac16c2790b38db0bd6f2376b81b5371
- Diff:
-
Revision 14 (+19 -8)
- Commit:
-
574147d9fac16c2790b38db0bd6f2376b81b5371255221a4d64da657d51c0f90fe2287d6ecfb3776
- Diff:
-
Revision 15 (+19 -8)