Placeholder Image

字幕列表 影片播放

  • Yeah, all right.

  • So since that's what the weather is doing today, I figured it's a perfect time for this one day build.

  • And what we're going to be building today is basically a pie phone screwed slash count of a shell script.

  • And what the script is gonna be able to do is automate the process of creating a new project for me.

  • And I'll show you what I mean by creating a new project.

  • So what?

  • The process of starting a new project usually looks like ISS.

  • I open a terminal window.

  • Then I navigate Thio where I usually keep my projects, which is in this folder.

  • So now I'm in my Projects folder and then I create a new folder called New Let's say and then once I've done that, I navigate into that project folder and then I create a read me file, and then I usually do get in it.

  • So I start a new kid, reports story, and then I go to get up dot com and I create a new repositories.

  • I name it knew, and then I create the report story, and then I copy this remote that you get here and I added to my party folder.

  • Then I do get ad gets commit, and then I do get pushed like so And then finally, the last part is I do code dot and I opened it in visual studio code.

  • So what I would like to do now is automate this entire process because this is what I do every time that I start a new project.

  • What I want to be able to dio is to create a terminal command that can be something like create.

  • And then the name of the project that I want to create lets a cow or something like that.

  • And then it should automatically navigate to the right folder.

  • And it should create a new folder called Cow, and then it should do this entire process automatically.

  • So I figured I I'll start with just riding up the all the different steps so that we have that.

  • All right, so this is now the to do list.

  • This is all the stuff that we have to d'oh.

  • So first navigate to my projects, create a folder with product name, navigate into that folder.

  • I get in a to go to get upgraded Europol story couple the remote at the remote to my local folder.

  • Creator read me file.

  • Do they get ad get committed, Get push and then co dot Which is what opens a visual studio cold for May.

  • So what I have to do now is kind of figure out what the best way to do this is.

  • And I think that the way that I'm gonna go about it, it's basically create a shell script with a command like create.

  • And then I can add some sort of input parameter life name with the folder.

  • And then that should run a Python script because I believe I need to do some, like, Web scraping, sort of things to be able to go to get up and get all that done.

  • And I think Python is really good for that.

  • So that's why I want to use Python for that.

  • But first, I'm just gonna research.

  • Try to find out what the best way to go about this way.

  • All right, so I kind of ran into a bit of a stupid problem, and that was that.

  • I was trying to run a Python script called Hello dot pie, but the pythons trip that I've created is called Create, DuPuy said.

  • There isn't a Python script called Hello DuPuy So of course it couldn't run.

  • It's basically is probably cause I followed this tutorial.

  • I didn't copy this.

  • I just like, was probably so into this kind of accidentally just wrote Hello.

  • DuPuy and I couldn't get it to run.

  • Couldn't figure out why, But now I was able to figure out why.

  • So, basically, now I'm just printing hello in this group.

  • But now if I type in create and some argument than it, sure just print hello first, and then it should also print the argument that I'm typing in.

  • So let's do clear.

  • So if I type in, create and then let's say cow than it should first print hello and then print Cal and it does that.

  • So now what I need to figure out is how to get this input parameter into the python script so that I can use it within the Python strip because right now I can do create and then I can type in something, and this is then what I want to be able to use as the folder name and get repositories name, though that's what I'm gonna try to figure out now.

  • All right, so I was able to figure it out, and now we're actually able to use the argument within the Python script.

  • And also, what I added is some navigation.

  • So basically, what I want to do is I want to be able to run this command from anywhere within any directory, and it should always put the new folder or the new project within a very specific folder that I want to put it in.

  • So what I added is basically this command here CD, which navigates back to the base directory.

  • Then we run the Python script, and then we navigate into the folder where I want to put the new project.

  • So when this runs now, what should happen is it should print whatever argument that I put in, and then it should navigate to my projects.

  • So let's run it and see what happens.

  • Actually, let's navigate to desktop just to show that even with Foreign another directory, we can still run the script.

  • Let's do create and then go cal.

  • So now it should print cow and navigate to my projects All right.

  • So we printed Cal, and it navigated to the my Projects folder so that works were able to navigate Thio the Projects folder.

  • Now the next step is to create a folder with the project name, and then we want to navigate into that.

  • All right, So they were able to create a folder and added to the right directory and were also able to do something which I think was pretty cool, which is just being able to open up a Web browser and go to get top dot com and then press the user name field.

  • All right, so let's just try to run it and hope that it works.

  • So what opens up?

  • Get up and it presses the username fields.

  • And now the next step is to basically just be able thio type in the use of name and then type in the password, and then press the sign in button and the way that we do this.

  • Like if you right click in Rome and then you press the inspector, Then you get all these different tabs, like elements, console sources, network, etcetera, basically on the elements.

  • You can get all of the hitch TML stuff.

  • So if we see this Dave here, we can see that.

  • Okay, That contains this.

  • And then we just keep moving until we find the element that we're looking for.

  • So this is an input, and the name is equal to log in the way that it worked.

  • I was able to just use this thing Thio press the log in.

  • But I think you can also do something like this If you write a cle and then you copy the ex path and then I can paste that here.

  • Yeah, I think that should work.

  • Not sure.

  • The over.

  • I think it should work.

  • All right, so let's try that.

  • And then I think that what I need to do is I think it's send cheese.

  • And then this is where we add the use of name like so.

  • And now what should happen is it should open up the Web browser and it should type in my user name.

  • Here is well again.

  • Let's run it and hope that it works.

  • Okay?

  • It wasn't able to do that.

  • Okay?

  • So it didn't work because I already created the folder and is trying to create another folder named Cal, which will not work.

  • So let's just not create a folder for now and then try to run it now.

  • It should work, I think.

  • Yeah, so it type saying my user name.

  • So now we just need to type in the password and then sign in.

  • So now I just need to do the same thing for the password.

  • And I did create a new password for this video, so I don't have to blur everything.

  • So basically, we just copy this and then faced it below, and then we need to find the ex path for the password.

  • So we go to the password here, and then we copy the ex path again.

  • And then we just added here TV, it works straight away.

  • Copy the password.

  • Pasted as this key that we want to send.

  • Save it and then let's try to run it.

  • I think we need to do single quotes on the password and then run it.

  • Yeah, so it does it pretty cool.

  • And now the last thing is just to press the signing button, and then we should be signed in.

  • Okay, so now it's time to test it.

  • Should just open up, Get up!

  • And Logan, that's basically all that.

  • It should.

  • D'oh!

  • That does it.

  • Yes.

  • So what does it?

  • It works.

  • Now, the next thing is just to figure out how to add a new repositories.

  • So we want to navigate to this thing here at a new report story.

  • Yep, that's next.

  • All right.

  • So I was able to solve it in a simple way, which is just that once I've logged in and all that stuff is done, then it basically just navigates to a new repositories to this link.

  • And now what we need to do is just create the repositories A ll, right?

  • I think this could be pretty good right now if I do create and then I run it and basically it opens this thing up, goes here.

  • My new project.

  • I think I think this is really cool.

  • I don't know why, but I think it's super cool.

  • And now all we have to do is basically press create depository.

  • And then, yeah, let's do that.

  • First problem is that I'm not able to get the right button here.

  • I'm so close to actually being able to make this work which is exciting, but it's like I just want finally Hell was able to figure out how to do it.

  • And now I use they see s s selector Thio get the button and the button is this button and then it basically submits it and creates a new report story.

  • So now if we just do create and say cows repo, then it will do everything for me.

  • It creates the repo.

  • All right, so now what we need to do is let's have a look at what we've done so far.

  • Go to gets hard and create a new report story copy.

  • The remote is now the next thing that we need to D'oh.

  • So let's do that.

  • Okay, um, I think this might be it, actually.

  • Well, we want to close the browser as well.

  • Well, we'll just start with this thing and then we'll see what it does.

  • And now we can try to actually create something.

  • So let's say that we want to create a depository Cold Water act.

  • Let's say this will go here and logs in it opened creates a depository called Water App, and then it should have done everything that I wanted it to D'oh!

  • I think it actually has.

  • Like it created the read me file, which is great.

  • Now, if we go Thio this one, we can see there's actually an initial commit Yes, all this.

  • I think this is pretty cool.

  • Like now all I have to do if I want Thio, create something.

  • Wherever I am in the terminal, all I have to do, which is I create.

  • And then I just have to type in whatever name of the folder that I want to create a the project that I want to create And then it will do everything else for me.

  • It will create the folder.

  • It will add a depository to get hub.

  • It will commit the first commit and either read me file.

  • And then it will open it up in visual studio code, which is where I usually work for everything that I d'oh!

  • I'm actually really happy with this.

  • That worked out really good.

  • All right, so now basically it should do the same thing as it did before, but then now, once it's created the thing, it should close yet.

  • So it closed the browser and then it opens this uh, this thing.

  • So that was the final step was just And that was your browser.

  • Doc quit.

  • And that did the whole thing.

  • So now it works, and now also added it to get help so that you can download it yourself and use it as well, in case you want to on DA.

  • I'll also add the link thio this repositories in the description of this video in case you wanna have a look or use it yourself.

  • So that's it for this one day build.

  • And like I said before, I'm really happy with the outcome of this project.

  • And I hope you enjoyed watching this, and that's it for this one.

Yeah, all right.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

一日構建。用Python自動化我的項目 (One Day Builds: Automating My Projects With Python)

  • 1 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字