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

Neaten up clarity of url handling, accommodate both http and https in build.py #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
target_name = args[0]
target_config = None

url = re.match(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', target_name)

# list all targets
if target_name == "ls":
for json_obj in test_json:
Expand All @@ -80,28 +82,28 @@
s += "(%s)" % json_obj["device_url"]
print(s)
exit(0)

# cycle through out targets and check for a match
for json_obj in test_json:
if json_obj["name"] != target_name:
continue

del json_obj["device_url"]
del json_obj["info"]

target_config = json_obj
break

if target_config == None and target_name.startswith("http"):
elif url:
# assume url is correct and set target config
target_config = {
"name": re.sub("^.*/", "", target_name),
"url": target_name,
"branch": "master",
"type": "git"
}
else:
# cycle through out targets and check for a match
for json_obj in test_json:
if json_obj["name"] != target_name:
continue

del json_obj["device_url"]
del json_obj["info"]

target_config = json_obj
break

if target_config == None:
print("'" + target_name + "'" + " is not a valid target.")
print("'" + target_name + "'" + " is not a valid target. Is the URL or target name correct?\r\n(\"python build.py ls\" lists pre-defined codal targets)")
exit(1)

# developer mode is for users who wish to contribute, it will clone and checkout commitable branches.
Expand Down