Skip to content

Instantly share code, notes, and snippets.

@tsileo
Last active December 17, 2015 04:49
Show Gist options
  • Save tsileo/5553570 to your computer and use it in GitHub Desktop.
Save tsileo/5553570 to your computer and use it in GitHub Desktop.
Bakthat debug GFS
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "GFS bakthat"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": "from grandfatherson import to_delete, to_keep\nfrom datetime import datetime, timedelta\n\nnow = datetime.utcnow()\ndts = [now]\n\n# Generating 50000 fake backups data with a 1hours interval from now\nfor i in range(50000):\n dts.append(dts[-1] - timedelta(hours=1))\n\nprint dts[0]\nprint dts[-1]",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "2013-05-10 10:08:04.004437\n2007-08-27 02:08:04.004437\n"
}
],
"prompt_number": 51
},
{
"cell_type": "code",
"collapsed": false,
"input": "import grandfatherson\nprint grandfatherson.MONDAY\nprint grandfatherson.SUNDAY",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "0\n6\n"
}
],
"prompt_number": 48
},
{
"cell_type": "code",
"collapsed": false,
"input": "from pprint import pprint\n\n# Check what GFS will keep\npprint([(d.strftime(\"%A\"), d) for d in sorted(to_keep(dts, now=now, hours=48, weeks=10, firstweekday=grandfatherson.MONDAY))])",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "[('Monday', datetime.datetime(2013, 3, 4, 0, 8, 4, 4437)),\n ('Saturday', datetime.datetime(2013, 3, 9, 0, 8, 4, 4437)),\n ('Saturday', datetime.datetime(2013, 3, 16, 0, 8, 4, 4437)),\n ('Saturday', datetime.datetime(2013, 3, 23, 0, 8, 4, 4437)),\n ('Saturday', datetime.datetime(2013, 3, 30, 0, 8, 4, 4437)),\n ('Saturday', datetime.datetime(2013, 4, 6, 0, 8, 4, 4437)),\n ('Saturday', datetime.datetime(2013, 4, 13, 0, 8, 4, 4437)),\n ('Saturday', datetime.datetime(2013, 4, 20, 0, 8, 4, 4437)),\n ('Saturday', datetime.datetime(2013, 4, 27, 0, 8, 4, 4437)),\n ('Saturday', datetime.datetime(2013, 5, 4, 0, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 11, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 12, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 13, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 14, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 15, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 16, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 17, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 18, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 19, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 20, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 21, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 22, 8, 4, 4437)),\n ('Wednesday', datetime.datetime(2013, 5, 8, 23, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 0, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 1, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 2, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 3, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 4, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 5, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 6, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 7, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 8, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 9, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 10, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 11, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 12, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 13, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 14, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 15, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 16, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 17, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 18, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 19, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 20, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 21, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 22, 8, 4, 4437)),\n ('Thursday', datetime.datetime(2013, 5, 9, 23, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 0, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 1, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 2, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 3, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 4, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 5, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 6, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 7, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 8, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 9, 8, 4, 4437)),\n ('Friday', datetime.datetime(2013, 5, 10, 10, 8, 4, 4437))]\n"
}
],
"prompt_number": 53
},
{
"cell_type": "code",
"collapsed": false,
"input": "",
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment