Utility/example for deleting empty project versions older than <d> days#174
Utility/example for deleting empty project versions older than <d> days#174
Conversation
| yield curr_date | ||
| curr_date += delta | ||
|
|
||
| def min_iso8601(): |
There was a problem hiding this comment.
While I am all for deleting code, are these methods that you just recently added e.g. this year? Generally, deleting or changing method signatures are considered as breaking backwards-compatibility in an API.
There was a problem hiding this comment.
None of these were in HubInstance - the only use they had was in demo_client, though I'll update that to use the two new methods.
There was a problem hiding this comment.
Okay I'm fine with deleting them.
|
|
||
| for project in bd.get_resource('projects'): | ||
| # skip projects younger than max age | ||
| if to_datetime(project.get('createdAt')) > max_age: continue |
There was a problem hiding this comment.
I'm getting an exception here: TypeError: can't compare offset-naive and offset-aware datetimes
There was a problem hiding this comment.
A possible solution could be to add something like this to utils:
// from dateutil.tz import tzlocal
def to_local_datetime(date):
return to_datetime(date).astimezone(tz=tzlocal())
def get_local_datetime():
return datetime.now(tz=tzlocal())
Normally I'd avoid creating wrappers for stl functions but in this case I don't think it is obvious how to get a timezone aware datetime given datetime.now() and even datetime.utcnow() are timezone naive. Thoughts?
There was a problem hiding this comment.
In sage_version_activity_to_csv.py I used: from dateutil.parser import isoparse
Would that work?
There was a problem hiding this comment.
I'll take a look at that tonight
|
You may find https://github.com/blackducksoftware/sage/blob/master/sage_version_activity_to_csv.py interesting as it creates a .csv with one line per project version. The .csv includes all columns I can think of containing decision criteria for deletion. The intended pipeline is to run Sage, then the above script, then filter_activity.py to trim the list to the stuff one just wants to delete. |
Was needing to write something like this anyway, though #173 gave me a little extra motivation :)
Note: I've not been able to fully test this script - please give it a go and let me know if everything looks right.