-
Notifications
You must be signed in to change notification settings - Fork 13
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
Finds last rev that built, and caches github #97
Conversation
bin/download-prebuilt-firmware.py
Outdated
import sys | ||
import time | ||
import urllib.request | ||
|
||
class Target_not_found(Exception): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class TargetNotFound(Exception):
bin/download-prebuilt-firmware.py
Outdated
archive_url = get_url(args) | ||
|
||
for rev in possible_revs: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To many new lines....
bin/download-prebuilt-firmware.py
Outdated
import doctest | ||
import json | ||
import os | ||
import pickle | ||
from pprint import pprint | ||
import sys | ||
import time | ||
import urllib.request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you order the imports
[H306] Alphabetically order your imports by the full module path. Organize your imports according to the Import order template and Real-world Import Order Examples below. For the purposes of import order, OpenStack projects other than the one to which the file belongs are considered “third party”. Only imports from the same Git repo are considered “project imports”
import a_standard
import b_standard
import a_third_party
import b_third_party
from a_soc import f
from a_soc import g
from b_soc import d
@CarlFK - I'll make you into a proper Python developer yet :-P |
I just disable the warning about pickle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you fix the title? BTW For WIP pull requests, please put WIP in the title.
Otherwise, with these minor fixes I'm happy to merge.
bin/download-prebuilt-firmware.py
Outdated
@@ -193,11 +227,33 @@ def get_targets(args, rev, targets_url): | |||
print("Did not find target {} for platform {} at rev {} (found {})". | |||
format(args.target, args.platform, rev, | |||
", ".join(possible_targets))) | |||
sys.exit(1) | |||
# pprint(possible_targets) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment.
On Wed, Feb 7, 2018 at 10:55 AM, Tim Ansell ***@***.***> wrote:
***@***.**** approved this pull request.
Can you fix the title? BTW For WIP pull requests, please put WIP in the
title.
Otherwise, with these minor fixes I'm happy to merge.
------------------------------
In bin/download-prebuilt-firmware.py
<#97 (comment)>
:
>
return possible_targets
+def find_last_rev(args, possible_revs):
So many new lines :-P
pep8 made me do it. 2 between each func def, right?
------------------------------
In bin/download-prebuilt-firmware.py
<#97 (comment)>
:
> @@ -193,11 +227,33 @@ def get_targets(args, rev, targets_url):
print("Did not find target {} for platform {} at rev {} (found {})".
format(args.target, args.platform, rev,
", ".join(possible_targets)))
- sys.exit(1)
+ # pprint(possible_targets)
Remove comment.
------------------------------
In bin/download-prebuilt-firmware.py
<#97 (comment)>
:
> +
+ cache = load_cache()
+ if url in cache and (cache_ttl is None or (
+ (datetime.now()-cache[url]['timestamp']).total_seconds() <
+ cache_ttl)):
+ data = cache[url]['data']
+ else:
+ while True:
+ data = json.loads(urllib.request.urlopen(url).read().decode())
+ if "message" in data:
+ print("Warning: {}".format(data["message"]))
+ time.sleep(1)
+ continue
+ else:
+ break
+ cache[url] = {
This wrapping must be wrong?
Hmm?
I'm guessing you mean that what gets read from the cache and what goes
upstream isn't right?
Or the cache[url] = should be somewhere else?
I kinda hated writing this because it's hard to understand.
If I had to do it over again I would find a package that has docs.
I considered adding a --use-cache option, "to make it easier to
understand" or something. that idea lasted about 30 seconds.
------------------------------
In bin/download-prebuilt-firmware.py
<#97 (comment)>
:
>
-def ls_github(url):
- while True:
- data = json.loads(urllib.request.urlopen(url).read().decode())
- if "message" in data:
- print("Warning: {}".format(data["message"]))
- time.sleep(1)
- continue
- return data
+
+class TargetNotFound(Exception):
+ pass
+
+
+def ls_github(url, cache_ttl=None):
+
FIXME: Move cache to a class
meh. I'm sure someone has done this already.
if any more work needs to be done, it is throw out my version and find a
package.
… —
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#97 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABauWXRFVVGb9muqs9moymeV-vM5BJgks5tSdWYgaJpZM4R6oZp>
.
--
Carl K
<blockquote><img src="https://assets-cdn.github.com/images/modules/open_graph/github-logo.png" width="48" align="right"><div><img src="https://assets-cdn.github.com/favicon.ico" height="14"> GitHub</div><div><strong><a href="https://github.com">Build software better, together</a></strong></div><div>GitHub is where people build software. More than 27 million people use GitHub to discover, fork, and contribute to over 77 million projects.</div></blockquote>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the title of the pull request to start with a capital.
|
||
return possible_targets | ||
|
||
|
||
def find_last_rev(args, possible_revs): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all the extra newlines inside the def find_last_rev
function.
time.sleep(1) | ||
continue | ||
else: | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please format the cache[url]
dictionary more normally. I think this is pep8 compliant?
cache[url] = {
'timestamp': datetime.now(),
'data': data,
}
LGTM! -- Merging. |
if the target isn't found,
find_last_rev(args, possible_revs) - prints the last ver and exits.
so now you can decide to get it:
ls_github(url) now saves its data to github.pickle -
2. special case for the top level dir. Age it - reload after 20 min.