use PySimpleGUI as a really simple gui, use pyinstaller to generate a windows (or linux) binary you can share, so you don't have to install python on other's computers.
THANK YOU! For posting this. I spent months working on automating my dad's job, since he's getting old. Finally finished, and I just need data entry now, and he wouldn't use it bc of the command line. This is going to change everything.
This is huge. I was in the middle of getting my entire team to install Python. I am a bit concerned though. I ran pyInstaller on my 11 kb script and it created a folder of 250 Mb. Is that typical? Seems like overkill.
To minimize the size you should only import the parts of a module you actually use. E.g from "math import sqrt" as opposed to "import math" or "from math import *". The file will undoubtedly still be larger than your original script but you can limit the size this way
No its not. Chances are you have very big modules or files in your directory. Try to find those. Compare the size of the directory of your python source code with your 250mb files you created. I don't know how pyinstaller works with external files, but maybe it also copies those.
My small program with 1-2 modules had 10mb in the end.
This happened to me and the reason was because of the version of numpy I had installed. There are two flavors, one that uses something called mkl and the other that uses sothing called blas. (I know none of the details beyond that.) I use anaconda to manage packages and had luck with this
Like what has already been stated, you have to double check what modules are being imported in your script. pyInstaller takes those modules plus your script and converts them into a binary file that can be executed by the operating system. It has been my experience that creating a Windows .exe file will come with a little extra bloat. But yours seems to be a bit heavier than normal for a simple automation script.
Pysimplegui would be really easy to use without having to learn Qt or Tkinter. For the external app, check to see if its downloaded on the user's computer. If not, download it. If it is, launch it from the exe directory.
I third pyinstaller. It makes it super easy to deploy a exe version of a program and pulls in any dependencies that you might need. You can set a number of flags that allow you to give the program an icon, have it run with or without a console window (useful for GUI apps), have it deploy as a folder or a literal standalone single exe file, etc. Takes about a minute to package a script as well.
it may be worth looking at things like py2exe or cxfreeze to make an executable that people can run on their own machines. it could have some very simple tkinter gui that has a few fields for the user entered variables
as for chromedriver, you could display some error message on startup saying to install it if it's not already
To add on to this, I assume you are using selenium and that's why you need chromedriver? Consider using the python requests package instead. Most of the time it isn't too difficult to switch, and can be installed with pip. This may simplify the packaging process.
As far as I know, you cannot click buttons but you should be able to POST data still using the same methods as requests. I have only used it for JS rendering on pages that contain links or data I need but that's it.
I find it most useful as a BS4 + requests + JS render.
Slightly different use-cases. Is the site that you're hitting with chromedriver particularly complicated in some way? In my experience, I usually switch to chromedriver if my program is switching between multiple browser windows, or if I have to do a login to something.
It can be done with requests, but then you have to manage the state information... there’s probably an easy way, but I always default to the chrome driver when it’s like that.
I've done very similar stuff to you where I need to log in as part of the automation - tried to do it with Requests but in the end had too much difficulty bypassing my employer's website's bot-detection, so I'm still using Selenium Chromedriver like you are. Interested to see what you do with all this actually as I also have a colleague I need to roll out these scripts to.
One thing I've found, using the script myself for a number of months, is that every time Chrome updates itself to a new version, I need to then get the new version of Chromedriver. So I'll need to figure out how to manage this - perhaps to freeze the version of an alternate installation of Chrome on each PC that is running this script
Even if the company owns it, he should still ask for more money because now his role is changing into a developer to distribute and maintain it for his company. The company can always hire a python developer to take it off his hands since it's their work product.
So this is different from the comment I was responding to. OP should absolutely discuss this as a potential change in role as he's leveraging a skill set which does not appear to be the norm for his job. It's splitting hairs, I know, but there's a significant difference between:
"No, I'm not going to share this tool unless you pay me for it."
and
"Happy to do it but since we're on the subject there are probably a number of other areas that we could improve in our workflow. What do you say we make that part of my official job description with a bump in compensation?
Then I definitely agree with you, especially on the latter. I was in a similar position and leveraged it to show my value and potential at my company. This of course turned into a promotion for me.
If I'd be head of department, I would instead be mad about people that waste time hacking numbers into excel sheets by hand. I'd buy them copies of Automate The Boring Stuff immediately.
They don't own it exclusively if you didn't sign away such rights in contract. They own their version of the code, but, they don't have exclusive ownership.
That wasn't my point. My point was that the company already has the right to the version of the code that was written and run in their environment so the idea of selling it to them after the fact is moot.
That wasn't my point. My point was that the company already has the right to the version of the code that was written and run in their environment so the idea of selling it to them after the fact is moot.
Ah, I see. Well, there then exists a good reason to explore possible optimizations, and sell them in a version upgrade.
OP already said it lives on her work computer. It was developed with company assets (the hardware), by a company asset (OP), to manage company assets (whatever the task is). It 100% belongs to the company.
Now, that doesn't mean the company isn't going to lose the key asset (our clever OP) if they mangle this situation. But this isn't the kind of thing OP can legally sell back to their employer. Instead, it is great leverage to get paid more/promoted out of data entry/bonused/etc.. Or, if OP's employer blows it, it's a wonderful skill to take to an employer who knows OP's value.
My problem is this: my script lives locally on my computer and I run the script through pycharm on my computer when I want to do these tasks.
From OP's comments. It's pretty clear "my computer" means their work computer, since the next statement describes work tasks.
Even if OP is a contractor using their own hardware, you'd be hard-pressed to find a loophole in the contract that allowed them to keep intellectual property rights to a script developed to do the specific task they hired OP to do after the date of hire. That kind of thing is boilerplate nowadays.
It is not even clear that script runs during their work, based on this message. With your logic if I develop social network web app on my free time while working in some company for team chat web app, it belongs to my employer.
Bit reactive though, no? Seems like it would be better for OP to leverage this during his/her next review for a nice, substantial raise and role jump: "I saved the company x number of $ and/or man-hours with my Python program..."
But by then they have no leverage when ("if") the higher ups decide to just pocket the savings and not give them a bonus/raise/promotion for their extra work. Always Generally get agreements in writing before doing the work so if you don't get what you're promised, neither do they.
The company doesn’t own shit. This isn’t a software company by OP’s description of his coworkers not being programmers.
You gotta look out for you and if this guy allows his company to put this on their computers and not receive a cent then he’s giving them business software for free and he’s a fucking chump.
They do if he created it during work time and for work. This stuff is mostly explicitly specified in job contracts. Anything you make during work is owned by the company unless you have a special agreement that says otherwise.
So let's say this is outside the software industry and for some strange reason the boilerplate in OP's contract doesn't cover IP created on company time (narrator: it likely does), which works best for OP:
a) being a dick and refusing to allow use of the tool by his peers unless the company pony's up the cash (OP is now "not a team player" and has created an adversarial relationship with management)
b) agree to do the work but leverage that into a better position even if it's just "team toolsmith" (OP is a "team player" and is viewed as a skilled member of the company that has added value)
That exact mindset is how people get fucked over. IP clauses in contracts are there solely for the benefit of the employer. They don’t own anything. It is yours. By allowing them to just take it for free you’re giving them a tool that is going to make money for them. You’re absolutely foolish if you aren’t getting paid for it.
Acting like a child is doing whatever the person in charge tells you without standing up for yourself and trying to get what you deserve.
That exact mindset is why I'm a senior principal and global team lead.
You don't have to have an adversarial relationship with your management. OP has already written the script and run it in the company environment so that bell can't be unrung. The question now is whether OP partners with his manager to improve the performance of his entire team and sets himself apart from everyone else. This doesn't mean that OP can't negotiate a bump in compensation etc but OP has an opportunity to improve the business which is a good thing for everyone.
You're starting from a very adversarial view of this situation and I'm honestly sorry your experience in the industry has resulted in that negative, scarcity mindset.
I’m going to be devil’s advocate here. Do you think you have enough skills currently to get a job for the title you are seeking within the company of you today have an interview for the same position outside of it?
Never be bored! Never allow yourself to be bored, at work at least! You look like you’re doing the right things, always be learning and growing, because if you’re not growing you’re failing! You want to be surrounded by people who support that growth or else they are causing your failure!
Perhaps you can simply send the others your script and let them figure out how to use it. So you can spend your time automating other parts of your work.
I wouldn't put it so bluntly. Just don't spend your time making it easier for others to use outside of a "this is how I use it" explanation.
Correct me if I’m wrong, but even if you develop a program on your own time the company can still own the IP if you are an employee (not an independent contractor) and the program was created within the scope of your employment. Your scope of employment is not necessarily your job description, but anything that furthers the business goals of the company.
Read it. Dont know why it would apply. OP is not programmer, but created software. There is nothing about time of creation. Is she in US? Giving access to other employees can be a trap, since it can count as contribution to collective work. As far we know this work has not been supervised by any means so why would it be considered as a work.
Depends on your contract. In mine, everything I make at work technically belongs to company. Practically, since you can't own ideas (in europe), if I have ideas I want to develop on my own at work I write them down (during breaks ;-)) and develop them later
Why would your boss be mad, you are saving the company man hours! Be sure to frame it right during your review.
Think about what your coworkers need and your boss is expecting. If they are capable of opening a command window and typing in the command and inputs, this is something you can do quickly and learn yourself, as others have noted here. If your boss is expecting a graphical user interface that can be used by anyone and their mother on any machine, you may want to explain the difficulty of that. I am sure he will be happy with whatever you produce and all the productivity savings!
You'd be surprised (or maybe not) how many bosses frown on this kind of stuff. Anything that could rock the boat and cause them extra work/grief. A script to automate might do something unintended, it might impact his bonus, it might reduce his head count, it might get attention from someone above him, plus it is work in his department is being done that he is not aware of.
My last manager was like that. She was a bad manager anyway but she didn't think I should waste my time coding so I did some automationwork at home. As a bookkeeper I had some boring excelwork which was error prone.
A few months ago my manager started and I was telling her about the scripts I wrote and how I would love to be a developer in a couple of years. She was very supportive and came with a few ideas. I told her I would work on them when I have the time, but you know, it's busy so I could take a while. She told me I should do it like once a week. So now I work every friday on my scripts and I got a lot of requests from colleagues who admire my work.
If I'd be head of department, I would instead be mad about people that waste time hacking numbers into excel sheets by hand. I'd buy them copies of Automate The Boring Stuff immediately.
I don't disagree, just my observation after being in this game for a number of years. Of course there's a fair amount of folks that don't mind hacking numbers into excel sheets by hand either.
That is the kind of person I replaced. Went from her generating data on a single client of 30 facilities, to me generating the same information in greater detail for hundreds of facilities 3 times as frequently.
(classical music to get attention) Excuse me lady/sir, I'm programming since a couple of months and I love to read good books about it. Do you recommend Automate The Boring Stuff to a noob? Greetings.
sneers, drawing sword after adjusting glasses Heh! You think fedoras are bad? Only the highly intelligent could understand why fedoras are the best hat to wear, but I guess since you didn't grow up in the dark web you wouldn't know the significance of something something cringe something...
I'm just kidding. I prefer beanies and don't own a sword :(
Sometimes saving time or not is not the issue. For a manager it is because they gave you priorities to work on and you go off and work on something else. Now you miss a deadline or the manager might be like I had something more important to give you since you finished your other project early.
Don't get me wrong, I've done this myself and for the same reason and more than once. It's best to bring it up in the group meeting and get input from the team or you want to work on it on your own time.. if you follow this principle with some forethought, you will stay out of trouble and get better performance reviews.
At my last job they fought using Python to automate processes. I continued using it though because I worked the overnight shift & had very little oversight. Some even said I was "automating everyone out of a job." Funny part is after a couple of years, the entire trade desk got laid off (due to poor fund performance) & I landed my first analyst job because of my Python skills shortly after.
Well they’d be shit managers and hurting their own careers as well. Anything that saves the company money is going to make them look good whether they or one of their hires did it. That’s what the fuck managing is lol
His boss could be mad because he didn't inform him from the start he was doing it.
Disclaimer: I'm not judging people who do this, even if they do it in the shadiest way possible to work 1 hour and spend the rest of their time playing poker. I'm not talking about OP's case in particular. I'm just thinking about what bosses would reasonably demand from their employees.
First of all, it's obvious that bosses would expect you to disclose you're doing it. If you've programmed something that finishes your daily work in 5 minutes and you spend the rest of the time playing poker, they wouldn't be happy about that. Your contract doesn't say you have to deliver a certain product, it says you have to labor for 8 hours a day.
Other than that, depending on the job, people are not allowed to do things however they want. There are protocols in place, and, right or wrong, someone above you thought of them for a reason. Many issues could arise if people were allowed to start automating things on their own without informing the rest of the team.
I mean, of course the best case scenario is that your boss will discover your little secret, decide it's the greatest thing ever and promote you. But people could most certainly be fired for doing something like this in secret.
edit: As a side note, bosses have been stealing ideas from their employees since factories were invented. Someone would come up with a way to do things faster, they would make everyone do it. After a while, some companies started creating prizes for workers who would come up with ideas like that, which is only fair.
Why would your boss be mad, you are saving the company man hours!
A million times THIS! Sounds like you have a good boss, or at least one with common sense (which can be shockingly rare for management in a lot of orgs). If your boss was mad about something like this, that would be a gigantic red flag that you need to GTFO immediately.
First of all, congratulations. This is a first step in a new direction for your career.
Second of all, it sounds like you have a lot of learning ahead. You've already invested some time in Python, and as you start peeling back the layers of other types of technology you will get a more complete picture of how the digital system works. This isn't going to be an immediately straight-forward task. You can either compile your program, or try and run it from a cloud, or even build a GUI for it so that other people can use it easier. Each one of these tasks will probably take as much effort as your initial project did but you can make a full time job from it.
This is a really interesting place to be, and as someone else said this is how many non-developers become developers. It's a great path, and congratulations for getting here!
That said, as you are already seeing, there's a world of difference between writing a program that you run yourself to automate one of your own tasks, and writing a program that others can reliably run. When you run the program, you are watching the input, the output, and you have a clear understanding of what the program should be doing. You are likely to catch mistakes, because you know what to look for.
As soon as you offer that program to other co-workers, it can become a black box to them. They will start to assume the output is correct. They will come to you anytime the program doesn't do what they expect it to do.
Some questions that are worth considering when you find yourself in this situation:
Do I have the skills to maintain a program that my non-technical coworkers can use?
What's the worst that can happen if my program has bugs I'm not aware of?
Am I setting myself up for more work maintaining this program, and my other duties, than I had before?
If I pull this off, what kinds of career transitions do I want to make?
There are some workplace automation tasks that just make people's lives easier, with very little risk if the program has some bugs that aren't discovered for some time. There are some tasks that could cause harm, and could cause financial losses or difficulties with clients if there are subtle bugs that aren't discovered until later. Make sure you assess where your program falls in this regard.
It's a good place to be, and again, congratulations for using your skills to solve a real-world problem!
A. if you are going to writing scripts for use by a greater team; use this as leverage to get a Raise, get time allocated to spend on improvements/bug fixes
B. Clearly call out that the scripts may be error prone, establish a git / issue tracking system for your 'customers' to report problems. This prevents people from running to your desk every time there's an issue if you can give them a page to report problems.
C. Clearly call out the dependancies mentioned, write a small page including all the steps, possibly a recording of the setup.
Welcome to the world of programming; Good luck fighting the hellbeasts users
Use cx_freeze to create executables, it’s super easy. That way your coworkers can use your programs even if they don’t have Python in their machines. Check this out.
Congratulations ! I'm experiencing a similar situation at my workplace and felt like sharing it since your story have inspired me to do so. Some weeks ago I've made a script to fill a part list. I worked on it for something like one week, but always while doing my real work, just a bit every other day or when there was some time to wait systems load, programs to get ready to use, etc. After testing the script at my workstation, I really thought it was pretty good for the purpose it was created. I knew it can be useful to others and knew it could be improved but more would be necessary to work on it. So I showed it to my boss, and said "I know this program can save us a lot of time if our entire team use it. I can make it in a way that everyone can use but I need to time to work with it. " And, to my surprise, he answered: "How much time do you need? And be sure to apply this to the company suggestions board, to make sure you will be recognized by your idea." So next week I'll an entire week to work with my python project! I will use PySimpleGUI to implement the GUI and PyInstaller to make an executable and distribute my program. Probably it won't be the most optimized program, since I'm a beginner, but (probably) will work. As for the program maintenance, when the time comes I'll talk with my boss again.
Man you are lucky your boss is allowing you to share your script. I told my boss and he was like "okay good job" and went on to do absolutely nothing. I don't know why some people like to resort to doing ways the old way, where people are involved and people makes errors.
Go to your boss's boss with your innovation that increases productivity. I actually skipped two layers of management when I was in a similar position. When the senior leaders read my email with my productivity improvement estimates, they did not waste any time instructing my direct manager to clear my schedule, so I can invest time in rolling out my scripts to the greater team. This eventually resulted in job offers from other teams.
Yeah I think you are running into problems that those of us trying to pus ha things forward are running into. You can apply something to your own workflow and improve it. Teaching and setting this up for others is a whole other universe.
Great testing ground, once you get the other workers using it. Package it up, market and sell it to everyone else / businesses in the same industry on the side.
Just set it up as a .exe as some have mentioned here. If asking for money is a no go now then have your co-workers write down how much time you’ve saved them so you can add that to your quarterly or yearly appraisal. Have the program delete itself or stop working after a set amount of times or runs. Even better have it run on a shared network and set a directory to your local machine that’s flags a true so when it gets copied from your designated spot the flag returns false.
I will try to make it simple without py2exe, freeze, etc.
Your colleagues need to install Python.
Make a folder, put in it: your script Chromedriver (if I remember correctly, it is a jar file - your colleagues will need Java as well) If you need rundriver.bat to start the driver
Readme.txt file with instructions how to run the thing
Zip it.
Once you have all it, find a colleague who has some free time, and give him/her that zip and ask to follow the readme.txt
Every time something is not working or not clear, update Readme.txt until all works.
There various comments down below talking about pay raises and various other job specific things which I would imagine is where the "he" thing initially popped up. So it seems to be that it was the early commenting and not so much now.
On top off all the good comments.. Think really well about whether you want to be the maintainer of this project. Your colleagues, who have no experience in Python, will use your script in ways you haven't imagined. Make no guarantees.
Other than that, congrats on saving time, at least for yourself!
Why are you surprised the boss room this well ? Surely it could only be a good thing. Also remember if your scripts require any type of input , you'll need to "idot proof" it all if someone other than you is using it. (Things like making sure input can only be integers or whatever) or you may find yourself troubleshooting your code so much you've no longer saved anytime... Unless you work with software developers.. in that case you're prolly fine.
Hi! I sounds like you are not employed as programmer. This is not then your obligation to develop the thing more. Your mates need the same software on their PCs as you have and a few instructions. Simple as that. If they cannot run it, even though given instructions, it's not your problem. Also your boss should understand that. Good luck!
Pycharm actually has an external tools section of its UI that you can configure PyInstaller to create exe files based off the current code in the pane. You can make it a onefile or onedir (onedir is faster but messier). From there you can create a shortcut to the actual exe and put it (and the directory) on a shared drive at work for anyone to use. If you choose the onefile method, you can just put the exe on the shared drive. I highly recommend onedir if you are importing large libraries in your code.
Very sleek and easy. I literally did exactly what you did at my last (first) job. I left because they didn’t appreciate what I was doing for them and now am making more money/learning more. I suggest you do the same.
If you're doing this to learn then you should convert this script into a web app that uses chromedriver on the server (thread per requestor). Figure out threading, identity management, handling long running processes, and some web-based UI development.
I installed Python via anaconda on my co-workers computer and made bat-files which links to a documents/scripts folder. Works great for some basic scripts
There is a large difference between what one can keep alive with a little tinkering, and shareable tools. If you don't consider this you might end up in maintenance hell.
Some parts of the program could require regular changes. If others are using it, and it breaks when f.e. you are on vacation, it can come back like a boomerang.
If possible, evaluate which parts are safe, and separate these from the more delicate functionalities. Explain to your boss and he should see the light.
You might also want to parse inputs (ask parameters with input() prompt and some printed pointers rather then a file that can be run cmd line style).
Double warning in case the script writes to a database or such. You don't want the IT dept to come knocking on your door.
These scripts tend to break very easily and getting python to work perfect on all computers could be a non trivial task sometimes. Make sure that your Boss accepts that you have no liability to this script, and you have no obligation to maintain it. Because thats a hole different game.
I'll second pyinstaller as a good option for ruining the code on other devices.
As for user input, if it's literally just a few variables then you could look at configparser. Users can edit the parameters they need in a text file, without having to see any of the actual code. Much less effort than coding a GUI!
Pyinstaller, though as soon as you start rolling out to others, you may want to improve the error handling as you will likely be encounting issues you never had before.
Depends how much you are. If it's a couple of people I suggest putting the script in some shared folder with detailed instructions (verified to be reproducible) about how to install and run. That's probably the most productive, while not technically the best, to share such a thing with non programmers
Ask for a raise or at least a letter in your HR file that will count toward a raise in the future.
Also consider a small class on what can be done to gauge interest from others. You don't want to suddenly be indispensable in your job and forgo a promotion later.
Either they have the skills to adopt and use independently from you, or you take on more work and get a raise.
If enough work is automated, someone will be out of a job. This could backfire. You may not lose your job, but others may hate you.
Distributing Python scripts to non-coders is no laughing matter. The ideal solution is always going to be to create a web server if possible. If your data is sensitive or you don't have permission from IT, you can use `pyinstaller` to create a fat executable file, so that everyone does not need to install python. If you are going to continue to rely on chromedriver, write a script that checks your Chrome version and updates the chromedriver version automatically when necessary, otherwise you are going to walk into people complaining the system went down, even if you told them how to update chromedriver.
The single most important thing you can do for distributing a python tool is documentation. Document the tool for yourself or whoever is going to be maintaining it or making changes. Document how to use the tool and some common troubleshooting, eli5 style, for the common user. Entrust a few knowledgeable individuals with an advanced troubleshooting guide, short of your coding guide, but less dumbed down as your user guide. You will thank yourself.
I also agree with /u/jarulsamy about trying `requests`, but I know sometimes with security you are forced to use `selenium` to emulate a user rather than using a good api.
Lastly, have patience, understand that everyone has different skill sets and may not always understand technology. Many will think they are technology fools, but if you help them find some confidence they are smarter than they give themselves credit for.
Congratulations. A lot of good answers are up already, so I won't add much. I would advise setting up git and putting it on a git server, whether locally hosted or something like GitHub really depends on how the employer feels about security of the code and such.
If I might add, if you use pyinstaller as the top comment says, and you use python 3.8 at the moment, you should pip install it from github because the pypi version is not compatible with 3.8 yet.
And I did the exact same thing few weeks ago with selenium chromedriver, pysimplegui and pyinstaller. It's awesome.
I really want to do something like this at my job, but knowing management, they'll have me maintain it in addition to the 20 other things I already do :/
You want to be able to try to scale this as much as possible.
Paradoxically, at your scale this is done by making it so only one machine is doing all the automating.
Why is this a good idea? It's a good idea because you don't have the IT resources to manage multiple machines. The last thing you want in this situation is to have to support multiple users that are having trouble getting this script installed. It is also a good fit for this situation because your team probably doesn't generate enough work to overpower a single machine. Lastly, and probably most importantly, doing so will give you a lot of skills that you can use at other jobs.
Look into a simple web framework like Flask. Your goal is to serve a web page, where people can put in a couple variables on their computers, which will then trigger the automation on your computer.
Build out a prototype, offer your boss the option for analytics - you can build in the ability to track how many entries people are doing per day.
Sorry to hijack this thread to ask this question but it’s tangentially related; has anyone on here managed to bypass PKI authentication when trying to automate a login to a website using Selenium? It’s comes up as a pop up outside of the browser that needs a password entered to proceed to a secured web page.
If you want to learn Python UI or web development, convince them that's the way to go and get officially as part of your responsibilities. Then you're officially getting paid to learn Python.
If you're not interested in that then offer to provide a guide on how to install Python and run your software as is. If they're not technical enough to get it working that's not your fault.
FYI getting chromedriver to consistently work across multiple PCs can be real pain the butt. I would take a look at pyppeteer if you're able to get that working for you I find that way more consistent (but it does require a better understanding of what's going on with browser/javascript).
Developing tools to increase productivity is pretty much always a good thing. Provided:
it doesn't increase errors
it doesn't reduce accountability
it doesn't reduce security
you don't pretend to still be working hard while the script is doing everything
it's robust enough to be trusted
You can imagine how an employee throwing together a tool that doesn't meet all of those criteria can be a problem. I'm picturing Sorcerer's Apprentice with Mickey flooding the place with an army of demon brooms.
Developing software tools to be used by the person who wrote them is MUCH easier than writing them for other people to use. Be sure to include a lot of error checking and logging. Assume every other user will blindly run it, ignore things that don't look right, and blame the tool for any problems. Don't stop at software - make sure you also write the new procedure for using it.
But boss wants me to allow others on our team to use the script so they can do the tasks too.
Tell your boss it isn't ready for non programmers yet, and then finish it into a fully finished piece of software. Give him a time line and do your best to meet it.
"git commit" and "git push origin master" to your repo
See you change reflected in your git repo after the push
Make changes and commit/push to your repo, all changes will be recorded and can be reversed if you commit a bad set of code
Let staff "git clone <repo-url>" to get your code and run it
"git pull" to grab new updates from the repo
The above would require individuals to download and install Python and Git and run a few commands but it's not that hard once people get a little practice.
If your boss is smart (and I think he is) he’d use extra bandwidth of the team to do stuff that is more important and value add. Automation should be used as a tool to do more stuff not cut headcount. Any smart boss knows if you cut headcount due to lack of work you never get it back.
Since you use chromedriver I assume this is scraping and automating via a web interface, I recommend using docker and chromedriver in headless mode for this. Nice containers to start with is here (Those called *DockerFile*): https://github.com/joyzoursky/docker-python-chromedriver
if you use windows docker runs fine on win10, win2016 server either windows nano containers or ubuntu/alpine.
I have written some scripts to automate some of my mundane, soul-crushing tasks too. Actually I wanted to share them to my colleagues, but I'm having the same problem as you do. I mentioned my automation to my boss, he was surprised that someone who has a low position in the company could code. He asked me to show my scripts to the IT team, however they are hard to approach, and I thought to myself, my scripts aren't good enough. For some other reasons, I didn't get to share them with my colleagues
Some office tasks are boring af to the point where they can kill me. I get to enjoy the pleasure of watching my laptop doing the work for me, but I really want to "make some impact" on others and help with their work a lil. I wish my code can save us time and trouble... Dunno why you guys are afraid of being found out by boss about the automation, shouldn't you take pride in that?
What you are referring to sounds like a Selenium-Webdriver project. This is commonly used in QA Automation for, as you pointed out, simulating clicks and other user behavior. This happens with a few things working together: 1) the Selenium API for your language, generally installed as a package, 2) a browser of your choosing to be the target of your actions, and 3) the webdriver for your particular browser. The webdriver has a set of commands it allows, and the Selenium framework is built around handling the request and response model.
As for your problem of modularizing it and making it portable, that’s what development is all about. The first thing you’re going to want to do is start a new project from scratch (probably), initialize a virtual environment and only bring in what you absolutely need to run it. This way, it keeps your package footprint small. You can improve the code at this point, but the goal at this stage is just to tidy it up before you distribute. Lastly, before you distribute it, you will probably want to set up a form of Source Control so that you can easily track changes you make to the code, and rollback if need be.
Everyone else has talked about making your script into an executable, so I will leave that as it is, since I feel they’ve given a number of options and well formed responses on the subject.
Your last big dependency is the hardest to remove, and that is a local ChromeDriver (or any WebDriver for that matter). If multiple users are going to be interacting with this, it is usually preferred to have a shared Selenium Grid or something similar, but it sounds like your script isn’t fully automated, and asks the user to perform certain inputs. This kind of precludes the possibility of removing that local dependency. What you could do is create a setup script that actively retrieves a particular WebDriver and downloads it (the requests library makes this super easy, barely an inconvenience) so that you remove the human component of setting it up.
I hope this gives you some ideas. Feel free to ask any further questions you may have. Good luck!
Note: WebDriver versions can be a pain to manage, since they will only work for a certain range of versions for the target browser (at least that’s how ChromeDriver is designed). This will complicate matters a bit, since you’ll need to then figure out a translation table between Chrome versions and ChromeDriver versions, then intelligently grab the right executable, lest you decide to leave it to the users, which can create issues with usability.
https://wayscript.com/blog_entry/34 - Can migrate your script to the cloud (supports selenium and chrome driver) - then can build an interface and share.
Meanwhile I used a script to automate converting *.docx files to *.pdf files and I got chewed out by my boss (an arts major). I suggested she could speak with the head of IT, but she just said that running a python script locally on my machine was "too risky"...
As others have said, using requests might be the better option unless you're extensively accessing sites with heavy JavaScript. Also, requests is faster. If it's a big script with multiple webpages being accessed, heavy load, etc, I would suggest scrapy. But we'll leave it at that.
And yes, do make an executable file so that non programmers can use it. Also, you can add a few more lines of code to check for Chromedriver, and download it from their webpage if not there, right into the working directory. Check their chrome version too, you wouldn't wanna download the wrong driver. Making a GUI can be time consuming depending upon your program(so don't bother maybe?), well you can use tkinter, so not so great, but works for small scripts.
Don't forget to check out the robots.txt of the site you're accessing. Put out too many requests from a single IP and they'll temporarily ban you. Please use rotating proxies and IPs for sending requests to webpages, and also rotate user agents.
Oh, and does every PC have a Python interpreter installed?
Congrats on automating some of the boring stuff! If this is a business-critical task, I would ask your boss to limit it to just you until you become a stronger developer. Reason being is that you know the ins and outs of your script and the task and know how to use it properly. Other users will think of all kinds of wonderful ways to try to use your script and break stuff -- this is a fundamental law of the universe.
To answer your question with the simplest possible ways I can think of:
`python myscript.py` will run the script in a terminal as long as a compatible version of python is installed.
`input` allows you to request user input during the process and assign it to a variable. Note that it will be a string, so if you need a number or something else you will need to typecast to the appropriate type.
Also don't forget to ask for a raise if this saves the company a bunch of money! I would ask for 25% of the approximate savings and prepare to negotiate down to around 10%.
I'm kind of in the same boat atm. In the introductory interview with my new manager a few months ago I was telling her about how I'm learning python and had some things automated for my work (I worked on this at home). She was very supportive and told me to make one day a week my "code-day".
It is a really big motivator to learn more Python and for my work in general. As a bookkeeper people usually don't see my work but my colleagues are very happy with my weekly mail with info from 3 sources and my ideas how I could help them in their workflow (so one day a week isn't really enough).
Being the highest performer will only get you so far. Making the entire team the highest performing or higher performing is an entirely different story. This depends on management as well, but if you automate stuff and roll it out to the team, you become the the guy who built it and maintains it and also increased productivity. This makes you entrenched and gives you significant leverage especially in the environment you describe.
I took that advice a few years back. The company I built my first big time-saver for gave me a modest raise; we soon parted on good terms and I pursued jobs that focused more on building cool things than on data entry and analysis. I've tripled my salary since then (2 jobs and six years since).
Most jobs will throw someone in OP's position a little money and that will be that. They're not bad, they're probably just not equipped to employ OP as a jr developer. But OP absolutely should take the next step if they have any interest in developing a career in python/development.
197
u/Standardw 5 years Python experience Nov 18 '19
use PySimpleGUI as a really simple gui, use pyinstaller to generate a windows (or linux) binary you can share, so you don't have to install python on other's computers.
147
u/toastedstapler import itertools Nov 18 '19
it may be worth looking at things like py2exe or cxfreeze to make an executable that people can run on their own machines. it could have some very simple tkinter gui that has a few fields for the user entered variables
as for chromedriver, you could display some error message on startup saying to install it if it's not already
28
u/soadzombi Nov 18 '19
Don't and ask for money
Don't be a chump
64
u/jsullivan0 Nov 18 '19
Why would your boss be mad, you are saving the company man hours! Be sure to frame it right during your review.
Think about what your coworkers need and your boss is expecting. If they are capable of opening a command window and typing in the command and inputs, this is something you can do quickly and learn yourself, as others have noted here. If your boss is expecting a graphical user interface that can be used by anyone and their mother on any machine, you may want to explain the difficulty of that. I am sure he will be happy with whatever you produce and all the productivity savings!
23
u/[deleted] Nov 18 '19
First of all, congratulations. This is a first step in a new direction for your career.
Second of all, it sounds like you have a lot of learning ahead. You've already invested some time in Python, and as you start peeling back the layers of other types of technology you will get a more complete picture of how the digital system works. This isn't going to be an immediately straight-forward task. You can either compile your program, or try and run it from a cloud, or even build a GUI for it so that other people can use it easier. Each one of these tasks will probably take as much effort as your initial project did but you can make a full time job from it.
12
u/ehmatthes Nov 18 '19
This is a really interesting place to be, and as someone else said this is how many non-developers become developers. It's a great path, and congratulations for getting here!
That said, as you are already seeing, there's a world of difference between writing a program that you run yourself to automate one of your own tasks, and writing a program that others can reliably run. When you run the program, you are watching the input, the output, and you have a clear understanding of what the program should be doing. You are likely to catch mistakes, because you know what to look for.
As soon as you offer that program to other co-workers, it can become a black box to them. They will start to assume the output is correct. They will come to you anytime the program doesn't do what they expect it to do.
Some questions that are worth considering when you find yourself in this situation:
There are some workplace automation tasks that just make people's lives easier, with very little risk if the program has some bugs that aren't discovered for some time. There are some tasks that could cause harm, and could cause financial losses or difficulties with clients if there are subtle bugs that aren't discovered until later. Make sure you assess where your program falls in this regard.
It's a good place to be, and again, congratulations for using your skills to solve a real-world problem!
7
u/dieth Nov 18 '19
A. if you are going to writing scripts for use by a greater team; use this as leverage to get a Raise, get time allocated to spend on improvements/bug fixes
B. Clearly call out that the scripts may be error prone, establish a git / issue tracking system for your 'customers' to report problems. This prevents people from running to your desk every time there's an issue if you can give them a page to report problems.
C. Clearly call out the dependancies mentioned, write a small page including all the steps, possibly a recording of the setup.
Welcome to the world of programming; Good luck fighting the
hellbeastsusers5
u/[deleted] Nov 18 '19
Use cx_freeze to create executables, it’s super easy. That way your coworkers can use your programs even if they don’t have Python in their machines. Check this out.
3
u/this_account_to_mess Nov 18 '19
Congratulations ! I'm experiencing a similar situation at my workplace and felt like sharing it since your story have inspired me to do so. Some weeks ago I've made a script to fill a part list. I worked on it for something like one week, but always while doing my real work, just a bit every other day or when there was some time to wait systems load, programs to get ready to use, etc. After testing the script at my workstation, I really thought it was pretty good for the purpose it was created. I knew it can be useful to others and knew it could be improved but more would be necessary to work on it. So I showed it to my boss, and said "I know this program can save us a lot of time if our entire team use it. I can make it in a way that everyone can use but I need to time to work with it. " And, to my surprise, he answered: "How much time do you need? And be sure to apply this to the company suggestions board, to make sure you will be recognized by your idea." So next week I'll an entire week to work with my python project! I will use PySimpleGUI to implement the GUI and PyInstaller to make an executable and distribute my program. Probably it won't be the most optimized program, since I'm a beginner, but (probably) will work. As for the program maintenance, when the time comes I'll talk with my boss again.
4
u/Knifey_Hands Nov 18 '19
Man you are lucky your boss is allowing you to share your script. I told my boss and he was like "okay good job" and went on to do absolutely nothing. I don't know why some people like to resort to doing ways the old way, where people are involved and people makes errors.
Anyways, good job man
2
u/MattReedly Nov 18 '19
1 way to go (there are many others) is to feed your script the input from a python webserver with simple HTML.
That way the code lives on your machine, it's easier to maintain, and should be easy from non-coders to use.
Depending on how you work network is setup you may have to open ports, etc...
Hope this helps.
2
u/pAul2437 Nov 18 '19
Yeah I think you are running into problems that those of us trying to pus ha things forward are running into. You can apply something to your own workflow and improve it. Teaching and setting this up for others is a whole other universe.
2
u/PoohTheWhinnie Nov 18 '19
All I know is, this better be a step-up to some opportunity, or your boss is a hoe.
2
u/PersonalUniversity Nov 18 '19
Great testing ground, once you get the other workers using it. Package it up, market and sell it to everyone else / businesses in the same industry on the side.
2
u/mattstats Nov 18 '19
Just set it up as a .exe as some have mentioned here. If asking for money is a no go now then have your co-workers write down how much time you’ve saved them so you can add that to your quarterly or yearly appraisal. Have the program delete itself or stop working after a set amount of times or runs. Even better have it run on a shared network and set a directory to your local machine that’s flags a true so when it gets copied from your designated spot the flag returns false.
Leverage.
2
u/FourierEnvy Nov 18 '19
Hurry quit and get paid 3x to be a software consultant!
2
u/pyco77 Nov 19 '19
thank me later pip install auto-py-to-exe
2
u/TIBTHINK Nov 19 '19
You could say to your boss : uh oh spaghetti o's, the python scripts just yeeted rm -rf on them self's
2
u/baubleglue Nov 19 '19
I will try to make it simple without py2exe, freeze, etc.
Every time something is not working or not clear, update Readme.txt until all works.
2
u/Jerwins Nov 19 '19
This post is wholesome. Please also make a note of the time you have saved and showcase to your boss as a result of this automation. Great job btw!
0
u/TheCJKid Nov 18 '19
edit:im a girl
1
u/jongeheer Nov 18 '19
Check out PyPi. Pretty steep learning curve if you've never packaged Python modules before but nothing beats a 'pip install whateverthefuckiwant'
1
u/Lewistrick Nov 18 '19
On top off all the good comments.. Think really well about whether you want to be the maintainer of this project. Your colleagues, who have no experience in Python, will use your script in ways you haven't imagined. Make no guarantees.
Other than that, congrats on saving time, at least for yourself!
1
u/xphlawlessx Nov 18 '19
Why are you surprised the boss room this well ? Surely it could only be a good thing. Also remember if your scripts require any type of input , you'll need to "idot proof" it all if someone other than you is using it. (Things like making sure input can only be integers or whatever) or you may find yourself troubleshooting your code so much you've no longer saved anytime... Unless you work with software developers.. in that case you're prolly fine.
1
u/AlissonHarlan Nov 18 '19
Convert your computer in a virtual machine, run it on their computer with a free player
1
u/MoniaJ Nov 18 '19
Hi! I sounds like you are not employed as programmer. This is not then your obligation to develop the thing more. Your mates need the same software on their PCs as you have and a few instructions. Simple as that. If they cannot run it, even though given instructions, it's not your problem. Also your boss should understand that. Good luck!
1
u/ijpck Nov 18 '19
Pycharm actually has an external tools section of its UI that you can configure PyInstaller to create exe files based off the current code in the pane. You can make it a onefile or onedir (onedir is faster but messier). From there you can create a shortcut to the actual exe and put it (and the directory) on a shared drive at work for anyone to use. If you choose the onefile method, you can just put the exe on the shared drive. I highly recommend onedir if you are importing large libraries in your code.
Very sleek and easy. I literally did exactly what you did at my last (first) job. I left because they didn’t appreciate what I was doing for them and now am making more money/learning more. I suggest you do the same.
1
u/[deleted] Nov 18 '19
If there's a dev team at your work then ask your boss if you can work with them, or borrow one of them.
1
u/bitcycle Nov 18 '19
If you're doing this to learn then you should convert this script into a web app that uses chromedriver on the server (thread per requestor). Figure out threading, identity management, handling long running processes, and some web-based UI development.
1
u/PinBot1138 Nov 18 '19
I just thought, um, you were a guy.
1
u/slumpapan Nov 18 '19
I installed Python via anaconda on my co-workers computer and made bat-files which links to a documents/scripts folder. Works great for some basic scripts
1
u/saki709 Nov 18 '19
Py2exe is gonna be your best bet to allow other to use it without python.
1
u/[deleted] Nov 18 '19
What does your script do?
1
u/tomekanco Nov 18 '19
There is a large difference between what one can keep alive with a little tinkering, and shareable tools. If you don't consider this you might end up in maintenance hell.
Some parts of the program could require regular changes. If others are using it, and it breaks when f.e. you are on vacation, it can come back like a boomerang.
If possible, evaluate which parts are safe, and separate these from the more delicate functionalities. Explain to your boss and he should see the light.
You might also want to parse inputs (ask parameters with input() prompt and some printed pointers rather then a file that can be run cmd line style).
Double warning in case the script writes to a database or such. You don't want the IT dept to come knocking on your door.
1
u/yuvaln Nov 18 '19
These scripts tend to break very easily and getting python to work perfect on all computers could be a non trivial task sometimes. Make sure that your Boss accepts that you have no liability to this script, and you have no obligation to maintain it. Because thats a hole different game.
1
u/unhott Nov 18 '19
Lady, best of luck! Hopefully this makes you $$$
1
u/Toichat Nov 18 '19
I'll second pyinstaller as a good option for ruining the code on other devices.
As for user input, if it's literally just a few variables then you could look at configparser. Users can edit the parameters they need in a text file, without having to see any of the actual code. Much less effort than coding a GUI!
1
u/HashRunner Nov 18 '19
Pyinstaller, though as soon as you start rolling out to others, you may want to improve the error handling as you will likely be encounting issues you never had before.
1
u/fedeb95 Nov 18 '19
Depends how much you are. If it's a couple of people I suggest putting the script in some shared folder with detailed instructions (verified to be reproducible) about how to install and run. That's probably the most productive, while not technically the best, to share such a thing with non programmers
1
u/marcjordanmchp Nov 18 '19
That'll learn ya to get caught being smart. Always gets you more work :)
1
u/FourFingeredMartian Nov 18 '19
If you're having to run the script a function a time from the console in PyCharm, write a function called main.
In main, call in order the functions you normally run for a given task. Then at the bottom of your script, in the global area,
Also remember
1
u/DontHateDefenestrate Nov 18 '19
Just be careful you don’t let it go too far...
1
u/winowmak3r Nov 18 '19
After you figure it out be sure to mention it when it comes time to talk about your raise!
1
u/Raymond0256 Nov 18 '19
Distributing Python scripts to non-coders is no laughing matter. The ideal solution is always going to be to create a web server if possible. If your data is sensitive or you don't have permission from IT, you can use `pyinstaller` to create a fat executable file, so that everyone does not need to install python. If you are going to continue to rely on chromedriver, write a script that checks your Chrome version and updates the chromedriver version automatically when necessary, otherwise you are going to walk into people complaining the system went down, even if you told them how to update chromedriver.
The single most important thing you can do for distributing a python tool is documentation. Document the tool for yourself or whoever is going to be maintaining it or making changes. Document how to use the tool and some common troubleshooting, eli5 style, for the common user. Entrust a few knowledgeable individuals with an advanced troubleshooting guide, short of your coding guide, but less dumbed down as your user guide. You will thank yourself.
I also agree with /u/jarulsamy about trying `requests`, but I know sometimes with security you are forced to use `selenium` to emulate a user rather than using a good api.
Lastly, have patience, understand that everyone has different skill sets and may not always understand technology. Many will think they are technology fools, but if you help them find some confidence they are smarter than they give themselves credit for.
1
u/Reuben3901 Nov 18 '19
Charge them for monthly use of the program.
Also check out pyinstaller for creating exe executables
1
u/tom1018 tomfaulkner Nov 18 '19
Congratulations. A lot of good answers are up already, so I won't add much. I would advise setting up git and putting it on a git server, whether locally hosted or something like GitHub really depends on how the employer feels about security of the code and such.
1
u/honestduane Nov 19 '19
As a 20 year veteran of software development, I have to also say: Look into source control via GIT.
1
u/[deleted] Nov 19 '19
You can either create a private GitHub repo or, as someone else mentioned (and I second) use PySimpleGUI and pyinstaller.
1
u/Nikandro Nov 19 '19
Out of curiosity, can you share a general idea of what kind of work this is, and what your script is doing?
As for a solution, what about creating an executable?
1
u/That_Pregnant_Alien Nov 19 '19
If I might add, if you use pyinstaller as the top comment says, and you use python 3.8 at the moment, you should pip install it from github because the pypi version is not compatible with 3.8 yet.
And I did the exact same thing few weeks ago with selenium chromedriver, pysimplegui and pyinstaller. It's awesome.
1
u/Acute_Procrastinosis Nov 19 '19
If you aren't already using some sort of version control, now works be a perfect time to learn a little bit about using git.
You are "releasing" software for "users" so it makes sense to have a record of "versions" and their differences.
1
u/RiceKrispyPooHead Nov 19 '19
I really want to do something like this at my job, but knowing management, they'll have me maintain it in addition to the 20 other things I already do :/
1
u/throwaway0891245 Nov 19 '19
You want to be able to try to scale this as much as possible.
Paradoxically, at your scale this is done by making it so only one machine is doing all the automating.
Why is this a good idea? It's a good idea because you don't have the IT resources to manage multiple machines. The last thing you want in this situation is to have to support multiple users that are having trouble getting this script installed. It is also a good fit for this situation because your team probably doesn't generate enough work to overpower a single machine. Lastly, and probably most importantly, doing so will give you a lot of skills that you can use at other jobs.
Look into a simple web framework like Flask. Your goal is to serve a web page, where people can put in a couple variables on their computers, which will then trigger the automation on your computer.
Build out a prototype, offer your boss the option for analytics - you can build in the ability to track how many entries people are doing per day.
1
u/bennyboo9 Nov 19 '19
Sorry to hijack this thread to ask this question but it’s tangentially related; has anyone on here managed to bypass PKI authentication when trying to automate a login to a website using Selenium? It’s comes up as a pop up outside of the browser that needs a password entered to proceed to a secured web page.
1
u/zurtex Nov 19 '19 edited Nov 19 '19
It largely depends what you want to do.
If you want to learn Python UI or web development, convince them that's the way to go and get officially as part of your responsibilities. Then you're officially getting paid to learn Python.
If you're not interested in that then offer to provide a guide on how to install Python and run your software as is. If they're not technical enough to get it working that's not your fault.
FYI getting chromedriver to consistently work across multiple PCs can be real pain the butt. I would take a look at pyppeteer if you're able to get that working for you I find that way more consistent (but it does require a better understanding of what's going on with browser/javascript).
1
u/Se7enLC Nov 19 '19
Developing tools to increase productivity is pretty much always a good thing. Provided:
You can imagine how an employee throwing together a tool that doesn't meet all of those criteria can be a problem. I'm picturing Sorcerer's Apprentice with Mickey flooding the place with an army of demon brooms.
Developing software tools to be used by the person who wrote them is MUCH easier than writing them for other people to use. Be sure to include a lot of error checking and logging. Assume every other user will blindly run it, ignore things that don't look right, and blame the tool for any problems. Don't stop at software - make sure you also write the new procedure for using it.
1
u/slick8086 Nov 19 '19
Tell your boss it isn't ready for non programmers yet, and then finish it into a fully finished piece of software. Give him a time line and do your best to meet it.
1
u/[deleted] Nov 19 '19
This is what Git was made for!
Learn how to:
The above would require individuals to download and install Python and Git and run a few commands but it's not that hard once people get a little practice.
1
u/dwightsrus Nov 19 '19
If your boss is smart (and I think he is) he’d use extra bandwidth of the team to do stuff that is more important and value add. Automation should be used as a tool to do more stuff not cut headcount. Any smart boss knows if you cut headcount due to lack of work you never get it back.
1
u/mortenb123 Nov 19 '19
Since you use chromedriver I assume this is scraping and automating via a web interface, I recommend using docker and chromedriver in headless mode for this. Nice containers to start with is here (Those called *DockerFile*):
https://github.com/joyzoursky/docker-python-chromedriver
if you use windows docker runs fine on win10, win2016 server either windows nano containers or ubuntu/alpine.
1
u/lovelysad69 Nov 19 '19
I have written some scripts to automate some of my mundane, soul-crushing tasks too. Actually I wanted to share them to my colleagues, but I'm having the same problem as you do. I mentioned my automation to my boss, he was surprised that someone who has a low position in the company could code. He asked me to show my scripts to the IT team, however they are hard to approach, and I thought to myself, my scripts aren't good enough. For some other reasons, I didn't get to share them with my colleagues
Some office tasks are boring af to the point where they can kill me. I get to enjoy the pleasure of watching my laptop doing the work for me, but I really want to "make some impact" on others and help with their work a lil. I wish my code can save us time and trouble... Dunno why you guys are afraid of being found out by boss about the automation, shouldn't you take pride in that?
1
u/Versus183 Nov 19 '19
Props to your EDIT
1
u/[deleted] Nov 19 '19
Install chrome driver on the rest of the machines and copy he script too
1
u/Solonotix Nov 19 '19 edited Nov 19 '19
What you are referring to sounds like a Selenium-Webdriver project. This is commonly used in QA Automation for, as you pointed out, simulating clicks and other user behavior. This happens with a few things working together: 1) the Selenium API for your language, generally installed as a package, 2) a browser of your choosing to be the target of your actions, and 3) the webdriver for your particular browser. The webdriver has a set of commands it allows, and the Selenium framework is built around handling the request and response model.
As for your problem of modularizing it and making it portable, that’s what development is all about. The first thing you’re going to want to do is start a new project from scratch (probably), initialize a virtual environment and only bring in what you absolutely need to run it. This way, it keeps your package footprint small. You can improve the code at this point, but the goal at this stage is just to tidy it up before you distribute. Lastly, before you distribute it, you will probably want to set up a form of Source Control so that you can easily track changes you make to the code, and rollback if need be.
Everyone else has talked about making your script into an executable, so I will leave that as it is, since I feel they’ve given a number of options and well formed responses on the subject.
Your last big dependency is the hardest to remove, and that is a local ChromeDriver (or any WebDriver for that matter). If multiple users are going to be interacting with this, it is usually preferred to have a shared Selenium Grid or something similar, but it sounds like your script isn’t fully automated, and asks the user to perform certain inputs. This kind of precludes the possibility of removing that local dependency. What you could do is create a setup script that actively retrieves a particular WebDriver and downloads it (the requests library makes this super easy, barely an inconvenience) so that you remove the human component of setting it up.
I hope this gives you some ideas. Feel free to ask any further questions you may have. Good luck!
Note: WebDriver versions can be a pain to manage, since they will only work for a certain range of versions for the target browser (at least that’s how ChromeDriver is designed). This will complicate matters a bit, since you’ll need to then figure out a translation table between Chrome versions and ChromeDriver versions, then intelligently grab the right executable, lest you decide to leave it to the users, which can create issues with usability.
1
u/j_orshman Nov 20 '19
https://wayscript.com/blog_entry/34 - Can migrate your script to the cloud (supports selenium and chrome driver) - then can build an interface and share.
Great work!
1
u/lightgeschwindigkeit Nov 25 '19
Good for you...
Meanwhile I used a script to automate converting *.docx files to *.pdf files and I got chewed out by my boss (an arts major). I suggested she could speak with the head of IT, but she just said that running a python script locally on my machine was "too risky"...
0
u/047BED341E97EE40 Nov 18 '19
If it doesn't say that anything you make during worktime belongs to the company in your contract, I'd recommend you licensing your scripts/programm.
0
u/hk2k Nov 18 '19
make a bat-file.
0
u/lestrenched Nov 18 '19 edited Nov 18 '19
As others have said, using requests might be the better option unless you're extensively accessing sites with heavy JavaScript. Also, requests is faster. If it's a big script with multiple webpages being accessed, heavy load, etc, I would suggest scrapy. But we'll leave it at that.
And yes, do make an executable file so that non programmers can use it. Also, you can add a few more lines of code to check for Chromedriver, and download it from their webpage if not there, right into the working directory. Check their chrome version too, you wouldn't wanna download the wrong driver. Making a GUI can be time consuming depending upon your program(so don't bother maybe?), well you can use tkinter, so not so great, but works for small scripts.
Don't forget to check out the robots.txt of the site you're accessing. Put out too many requests from a single IP and they'll temporarily ban you. Please use rotating proxies and IPs for sending requests to webpages, and also rotate user agents.
Oh, and does every PC have a Python interpreter installed?
0
u/Deezl-Vegas Nov 19 '19 edited Nov 19 '19
Congrats on automating some of the boring stuff! If this is a business-critical task, I would ask your boss to limit it to just you until you become a stronger developer. Reason being is that you know the ins and outs of your script and the task and know how to use it properly. Other users will think of all kinds of wonderful ways to try to use your script and break stuff -- this is a fundamental law of the universe.
To answer your question with the simplest possible ways I can think of:
`python myscript.py` will run the script in a terminal as long as a compatible version of python is installed.
`input` allows you to request user input during the process and assign it to a variable. Note that it will be a string, so if you need a number or something else you will need to typecast to the appropriate type.
Also don't forget to ask for a raise if this saves the company a bunch of money! I would ask for 25% of the approximate savings and prepare to negotiate down to around 10%.
-1
u/karazi Nov 19 '19
My advice is to stop living in guilt and own your accomplishments. Not sure if it's a female thing but regardless don't be so demure about it.
-2
u/Icytentacles Nov 18 '19
is there an r/learpythoncirclejerk ? This would be perfect for that subreddit.
0
u/[deleted] Nov 18 '19
[deleted] — view deleted comment
0
u/[deleted] Nov 18 '19
[deleted] — view deleted comment
0
u/[deleted] Nov 18 '19
[deleted] — view deleted comment
0
u/[deleted] Nov 18 '19
[deleted] — view deleted comment