Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Review Only - Do Not Merge] Adham/scripts #11

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

phillipjohnston
Copy link
Member

No description provided.

@phillipjohnston
Copy link
Member Author

Hi @AdhamEA - please see the review comments I have made in this pull request. Best way to look at it is with the "Files" tab.

You can open a pull request with your branch next time, and I will see it and be able to give you a code review. You can do this even if you are not ready to merge. Just add something like [Review Only] to the title.

@AdhamEA AdhamEA self-requested a review August 16, 2022 16:40
from git import Repo


USE_ADR=0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Adham,

For variable names, you can use lowercase (use_adr). The upper case is a convention that came from Bash files, but isn't necessary here.

This seems like a reasonable style guide to follow: https://peps.python.org/pep-0008/#global-variable-names

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

Variable names follow the same convention as function names.


#variable=len(opts)
#for i in range(1,variable) :
# del opts[i]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be deleted before merging.

#for i in range(1,variable) :
# del opts[i]

CHECK_DIR="c:/subprojects"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability purposes, I prefer having a space around the "="

CHECK_DIR = "c:/subprojects"

But also, this variable should not be hardcoded to that particular folder, right?


DEST_DIR=args[0]
DEST_PATH_2= os.path.exists(f"{args[0]}")
if(DEST_PATH_2==False):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have a DEST_DIR variable, you should reference that instead of args[0] int his section of code.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean instead of f"args[0]" i need to put f"{DEST_DIR}" ? right ?

CHECK_PATH_1= os.path.exists(f"{CHECK_DIR}/Tools")
if(CHECK_PATH_1==False):
CHECK_DIR=os.chdir(f"{CHECK_DIR}")
CHECK_PATH_1= os.path.exists(f"{CHECK_DIR}")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the "f" mean here?

(f"{CHECK_DIR}")

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f strings is a way to replace variables with its values : lets take on consideration this example :
VAL = 5
print(f "val = {VAL}")
the output :
val = 5
https://www.geeksforgeeks.org/formatted-string-literals-f-strings-python/

# taking arguments from the client
args=sys.argv[1:]
if (args[0]==None):
TOOLCHAIN_INSTALL_DIR = "/usr/local/toolchains "
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The space at the end is not needed.

# Download and install dependency #
###################################

os.chdir('c:\\tmp')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same tmp problem here

elif o == "-s":
HOME=input("Give Home Directory :")
else :
print("erreur + help function ")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you actually print a help function here? :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha sure it was just a reminder print so i can write it later :D

if(platform.release()=="Darwin"):
os.system(f"cat {HOME}/.bash_profile")
if (os.path.isfile("c:/.bash_profile")==True):
exec(open('c:/.bash_profile').read())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what this section of code is doing?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on the bash script
if [ "$(uname)" == "Darwin" ]; then
cat << ENDOFBLOCK >> $HOME/.bash_profile
if [ -f $HOME/.bashrc ]; then
source $HOME/.bashrc
fi
first i checked if the platform system is Mac (i need to change platform.release to platform.system) then since i didnt find any equivalent bash command " cat " in python scripts i used os.system() function
then i checked if the $HOME/.bashrc is actually a regular file and not directory

https://tldp.org/LDP/abs/html/fto.html

@@ -0,0 +1,12 @@
*.pdf filter=lfs diff=lfs merge=lfs -text
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File should not be included - accidental commit, probably from running the script :).

Same is true for the .github folder, tools/.gitignore, and tools/subprojects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants