Automatically download chrome driver. #92

Merged
esirK merged 4 commits from driver_install into master 5 years ago
esirK commented 5 years ago (Migrated from github.com)
Owner

Automatically downloads chrome driver for users according to their os platform.

Automatically downloads chrome driver for users according to their os platform.
esirK (Migrated from github.com) reviewed 5 years ago
esirK (Migrated from github.com) commented 5 years ago
Poster
Owner

I think we should have a way to dynamically get the latest chrome driver instead of statically hard-coding them.

I think we should have a way to dynamically get the latest chrome driver instead of statically hard-coding them.
weskerfoot (Migrated from github.com) reviewed 5 years ago
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

Yeah, I was thinking that actually. It's not great to have to update the URL every time there's a new release.

Yeah, I was thinking that actually. It's not great to have to update the URL every time there's a new release.
weskerfoot commented 5 years ago (Migrated from github.com)
Owner

I'll try to review this today or tomorrow, thanks for the work!

I'll try to review this today or tomorrow, thanks for the work!
weskerfoot (Migrated from github.com) reviewed 5 years ago
If Not, Download it.
"""
cwd = os.listdir(os.getcwd())
webdriver_regex = re.compile('chromedriver')
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

We could maybe also construct the expected filename (i.e. chromedriver_platform.zip based on platform.system() like you're doing below

We could maybe also construct the expected filename (i.e. `chromedriver_platform.zip` based on `platform.system()` like you're doing below
weskerfoot (Migrated from github.com) requested changes 5 years ago
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

I'd prefer not shadowing the builtin file() constructor

I'd prefer not shadowing the builtin `file()` constructor
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

I like to pass an exit code when calling sys.exit(), so e.g. sys.exit(1) just to be more explicit about the error codes

I like to pass an exit code when calling `sys.exit()`, so e.g. `sys.exit(1)` just to be more explicit about the error codes
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

just change this to be a single line return webdriver.Chrome(executable_path=driver_path, options=options)

just change this to be a single line `return webdriver.Chrome(executable_path=driver_path, options=options)`
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

I'd prefer something like return "{0}/chromedriver".format(os.getcwd()) just for sylistic reasons

I'd prefer something like `return "{0}/chromedriver".format(os.getcwd())` just for sylistic reasons
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

maybe webdrivers should be a namedtuple or something at the top level scope of the module? Then you could do webdrivers.darwin or webdrivers.linux, etc

maybe webdrivers should be a namedtuple or something at the top level scope of the module? Then you could do `webdrivers.darwin` or `webdrivers.linux`, etc
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

Might be good to create our own exception type here but I think it's fine as is

Might be good to create our own exception type here but I think it's fine as is
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

Like I mentioned in my other comment I think using the .format() method of strings should be the way to do this (feel free to disagree, I just think it's a good convention to follow)

Like I mentioned in my other comment I think using the `.format()` method of strings should be the way to do this (feel free to disagree, I just think it's a good convention to follow)
pbar.finish()
puts(colored.yellow("Downloading Chrome Webdriver"))
file_name = chrome_webdriver.split('/')[-1]
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

_, file_name = os.path.split(chrome_webdriver) would be clearer IMO

`_, file_name = os.path.split(chrome_webdriver)` would be clearer IMO
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

I use _ just to signify that we don't care about the first part of the tuple that os.path.split returns, but you could just as well do os.path.split(chrome_webdriver)[1] to get it

I use `_` just to signify that we don't care about the first part of the tuple that `os.path.split` returns, but you could just as well do `os.path.split(chrome_webdriver)[1]` to get it
esirK (Migrated from github.com) reviewed 5 years ago
esirK (Migrated from github.com) commented 5 years ago
Poster
Owner

Any Ideas on how we can do this?

Any Ideas on how we can do this?
esirK (Migrated from github.com) reviewed 5 years ago
esirK (Migrated from github.com) commented 5 years ago
Poster
Owner

makes sense.

makes sense.
esirK (Migrated from github.com) reviewed 5 years ago
esirK (Migrated from github.com) commented 5 years ago
Poster
Owner

True. But I will go ahead and create our own Exception file just incase someone needs to add more exceptions in future.

True. But I will go ahead and create our own Exception file just incase someone needs to add more exceptions in future.
esirK (Migrated from github.com) reviewed 5 years ago
pbar.finish()
puts(colored.yellow("Downloading Chrome Webdriver"))
file_name = chrome_webdriver.split('/')[-1]
esirK (Migrated from github.com) commented 5 years ago
Poster
Owner

_, file_name = os.path.split(chrome_webdriver) would be clearer IMO

IMHO, I think this wouldn't be clearer since we will be making the person reading the code think that chrome_webdriver is a file system path which is not. I think what we can do is add a comment before file_name = chrome_webdriver.split('/')[-1] saying create filename from chrome_webdriver url. What do you think?

> `_, file_name = os.path.split(chrome_webdriver)` would be clearer IMO IMHO, I think this wouldn't be clearer since we will be making the person reading the code think that `chrome_webdriver` is a file system path which is not. I think what we can do is add a comment before `file_name = chrome_webdriver.split('/')[-1]` saying **create filename from chrome_webdriver url.** What do you think?
esirK (Migrated from github.com) reviewed 5 years ago
esirK (Migrated from github.com) commented 5 years ago
Poster
Owner

Like I mentioned in my other comment I think using the .format() method of strings should be the way to do this (feel free to disagree, I just think it's a good convention to follow)

I totally agree with this. I would prefer f strings but I am sure not everyone is using python>=3.6 🙂

> Like I mentioned in my other comment I think using the `.format()` method of strings should be the way to do this (feel free to disagree, I just think it's a good convention to follow) I totally agree with this. I would prefer `f` strings but I am sure not everyone is using python>=3.6 🙂
weskerfoot (Migrated from github.com) reviewed 5 years ago
pbar.finish()
puts(colored.yellow("Downloading Chrome Webdriver"))
file_name = chrome_webdriver.split('/')[-1]
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

Good point, I didn't realize at first that it was supposed to be a URL and not an actual path being split. A comment would help.

Good point, I didn't realize at first that it was supposed to be a URL and not an actual path being split. A comment would help.
weskerfoot commented 5 years ago (Migrated from github.com)
Owner

I'm going to test it out as well and make sure it works for me

I'm going to test it out as well and make sure it works for me
weskerfoot (Migrated from github.com) reviewed 5 years ago
weskerfoot (Migrated from github.com) commented 5 years ago
Owner

I can handle it in a separate PR. I have some ideas for how to do it nicely.

I can handle it in a separate PR. I have some ideas for how to do it nicely.
weskerfoot commented 5 years ago (Migrated from github.com)
Owner

Seems to work for me on Arch Linux. I'm going to merge it and then I have some ideas for how to handle versioning it a bit better.

Thanks for the help!

Seems to work for me on Arch Linux. I'm going to merge it and then I have some ideas for how to handle versioning it a bit better. Thanks for the help!

Reviewers

The pull request has been merged as 881296cd59.
Sign in to join this conversation.
Loading…
There is no content yet.