-
Notifications
You must be signed in to change notification settings - Fork 141
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
Add option to add specific center or doctor #83
Open
Dreiundzwanzig
wants to merge
3
commits into
rbignon:master
Choose a base branch
from
Dreiundzwanzig:feature/add_specific_center
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -617,6 +617,16 @@ def setup_loggers(self, level): | |
logging.root.setLevel(level) | ||
logging.root.addHandler(self.create_default_logger()) | ||
|
||
def try_to_book_or_sleep(self, docto, center, vaccine_list, start_date, end_date, only_second, only_third, dry_run=False): | ||
if docto.try_to_book(center, vaccine_list, start_date, end_date, only_second, only_third, dry_run): | ||
log('') | ||
log('💉 %s Congratulations.' % | ||
colored('Booked!', 'green', attrs=('bold',))) | ||
return True | ||
|
||
sleep(SLEEP_INTERVAL_AFTER_CENTER) | ||
return False | ||
|
||
def main(self, cli_args=None): | ||
colorama.init() # needed for windows | ||
|
||
|
@@ -653,6 +663,8 @@ def main(self, cli_args=None): | |
action='append', help='exclude centers') | ||
parser.add_argument('--center-exclude-regex', | ||
action='append', help='exclude centers by regex') | ||
parser.add_argument('--additional-center', '-ac', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Until now, we only had single-letter abbreviations for arguments but it looks like we are running out of usable letters. Still it should be a deliberate decision to extend to two-letter abbreviations. @rbignon what do you think? |
||
action='append', help='Add additional centers or doctors: "url" e.g. "/institut/berlin/ciz-berlin-berlin"') | ||
parser.add_argument( | ||
'--include-neighbor-city', '-n', action='store_true', help='include neighboring cities') | ||
parser.add_argument('--start-date', type=str, default=None, | ||
|
@@ -669,8 +681,6 @@ def main(self, cli_args=None): | |
parser.add_argument('--code', type=str, default=None, help='2FA code') | ||
args = parser.parse_args(cli_args if cli_args else sys.argv[1:]) | ||
|
||
from types import SimpleNamespace | ||
|
||
if args.debug: | ||
responses_dirname = tempfile.mkdtemp(prefix='woob_session_') | ||
self.setup_loggers(logging.DEBUG) | ||
|
@@ -827,18 +837,19 @@ def main(self, cli_args=None): | |
continue | ||
|
||
log('') | ||
|
||
log('Center %(name_with_title)s (%(city)s):' % center) | ||
|
||
if docto.try_to_book(center, vaccine_list, start_date, end_date, args.only_second, args.only_third, args.dry_run): | ||
log('') | ||
log('💉 %s Congratulations.' % | ||
colored('Booked!', 'green', attrs=('bold',))) | ||
if self.try_to_book_or_sleep(docto, center, vaccine_list, start_date, end_date, args.only_second, args.only_third, args.dry_run): | ||
return 0 | ||
|
||
sleep(SLEEP_INTERVAL_AFTER_CENTER) | ||
if args.additional_center: | ||
for additional_center in args.additional_center: | ||
log('') | ||
log('Additional center %s:', additional_center.split('/')[-1]) | ||
|
||
if self.try_to_book_or_sleep(docto, { "url": additional_center }, vaccine_list, start_date, end_date, args.only_second, args.only_third, args.dry_run): | ||
return 0 | ||
|
||
log('') | ||
log('No free slots found at selected centers. Trying another round in %s sec...', SLEEP_INTERVAL_AFTER_RUN) | ||
sleep(SLEEP_INTERVAL_AFTER_RUN) | ||
except CityNotFound as e: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me the method name is a bit misleading. "or sleep" in fact describes the internal logic of a lazy loading
try_to_book || sleep
but from the sound of it I would expect "or sleep" is related to the return value. Maybe someone comes up with a better name?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah your right, i guess we could just use
try_to_book
? I mean it's just that and in fact it does not matter if there is asleep
inside or not. What do you think?