Skip to content

Instantly share code, notes, and snippets.

@hiromis
Created January 22, 2021 20:20
Show Gist options
  • Save hiromis/71ffde8fd5f08b55bade42f7da8c2d25 to your computer and use it in GitHub Desktop.
Save hiromis/71ffde8fd5f08b55bade42f7da8c2d25 to your computer and use it in GitHub Desktop.
docs/test.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "from pygmdata.pygmdata import Data",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "data = Data(\"http://localhost:8181\", \n USER_DN='CN=hiromi.suenaga,OU=Engineering,O=Decipher Technology Studios,L=Alexandria,ST=Virginia,C=US', \n log_level=\"debug\")",
"execution_count": 2,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": "2021-01-22 14:11:55,522 - pygmdata - DEBUG - path: /world, oid: 1\n"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "data.get_self()",
"execution_count": 3,
"outputs": [
{
"data": {
"text/plain": "'{\"label\":\"CN=hiromi.suenaga,OU=Engineering,O=Decipher Technology Studios,L=Alexandria,ST=Virginia,C=US\",\"exp\":1611376249,\"iss\":\"greymatter.io\",\"values\":{\"email\":[\"hiromi.suenaga@greymatter.io\"],\"org\":[\"greymatter.io\",\"deciphernow.com\"]}}'"
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "op = '(if (contains email \"hiromi.suenaga@greymatter.io\")(yield-all)(yield R X))'",
"execution_count": 4,
"outputs": []
},
{
"metadata": {
"scrolled": false,
"trusted": true
},
"cell_type": "code",
"source": "data.make_directory_tree('/world/hiromi.suenaga@greymatter.io/images', lisp_object_policy=op)",
"execution_count": 5,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": "2021-01-22 14:11:59,591 - pygmdata - DEBUG - path: /world, oid: 1\n2021-01-22 14:11:59,625 - pygmdata - DEBUG - Looking for /world/hiromi.suenaga@greymatter.io, oid None\n2021-01-22 14:11:59,626 - pygmdata - DEBUG - Path /world/hiromi.suenaga@greymatter.io not found, creating parent\n2021-01-22 14:11:59,626 - pygmdata - DEBUG - Looking for /world, oid 165c9f359d6082ec\n2021-01-22 14:11:59,627 - pygmdata - DEBUG - New file under parent OID: 165c9f359d6082ec\n2021-01-22 14:11:59,660 - pygmdata - DEBUG - The sent request\n2021-01-22 14:11:59,660 - pygmdata - DEBUG - URL: http://localhost:8181/write\n2021-01-22 14:11:59,661 - pygmdata - DEBUG - Body: b'--9225f7a615854aefb62a591fe809e052\\r\\nContent-Disposition: form-data; name=\"file\"; filename=\"meta\"\\r\\n\\r\\n[{\"action\": \"C\", \"name\": \"hiromi.suenaga@greymatter.io\", \"parentoid\": \"165c9f359d6082ec\", \"isFile\": false, \"originalobjectpolicy\": \"(if (contains email \\\\\"hiromi.suenaga@greymatter.io\\\\\")(yield-all)(yield R X))\", \"security\": {\"label\": \"DECIPHER//GMDATA\", \"foreground\": \"#FFFFFF\", \"background\": \"green\"}}]\\r\\n--9225f7a615854aefb62a591fe809e052--\\r\\n'\n2021-01-22 14:11:59,662 - pygmdata - DEBUG - Headers: {'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'USER_DN': 'CN=hiromi.suenaga,OU=Engineering,O=Decipher Technology Studios,L=Alexandria,ST=Virginia,C=US', 'Content-Length': '442', 'Content-Type': 'multipart/form-data; boundary=9225f7a615854aefb62a591fe809e052'}\n2021-01-22 14:11:59,663 - pygmdata - DEBUG - Response\n2021-01-22 14:11:59,663 - pygmdata - DEBUG - 200\n2021-01-22 14:11:59,664 - pygmdata - DEBUG - [{'tstamp': '165ca6f0c243d920', 'userpolicy': {'label': 'CN=hiromi.suenaga,OU=Engineering,O=Decipher Technology Studios,L=Alexandria,ST=Virginia,C=US'}, 'jwthash': 'dfdb11306b33079c43cd644aea4c2b976e4f97a089c7eb689ae5328b14d26ec8', 'schemaversion': 10, 'name': 'hiromi.suenaga@greymatter.io', 'action': 'C', 'oid': '165ca6f0c2300d8c', 'parentoid': '165c9f359d6082ec', 'expiration': '7fffffffffffffff', 'checkedtstamp': '165c9f359d6b36c4', 'objectpolicy': {'requirements': {'f': 'if', 'a': [{'f': 'contains', 'a': [{'v': 'email'}, {'v': 'hiromi.suenaga@greymatter.io'}]}, {'f': 'yield-all'}, {'f': 'yield', 'a': [{'v': 'R'}, {'v': 'X'}]}]}}, 'derived': {}, 'security': {'label': 'DECIPHER//GMDATA', 'foreground': '#FFFFFF', 'background': 'green'}, 'originalobjectpolicy': '(if (contains email \"hiromi.suenaga@greymatter.io\")(yield-all)(yield R X))', 'cluster': 'default'}]\n2021-01-22 14:11:59,697 - pygmdata - DEBUG - path: /world, oid: 1\n2021-01-22 14:11:59,732 - pygmdata - DEBUG - path: /world/hiromi.suenaga@greymatter.io, oid: 165c9f359d6082ec\n2021-01-22 14:11:59,768 - pygmdata - DEBUG - New file under parent OID: 165ca6f0c2300d8c\n2021-01-22 14:11:59,802 - pygmdata - DEBUG - The sent request\n2021-01-22 14:11:59,802 - pygmdata - DEBUG - URL: http://localhost:8181/write\n2021-01-22 14:11:59,803 - pygmdata - DEBUG - Body: b'--4d89249fa31cb8fa11b85fb3d5069385\\r\\nContent-Disposition: form-data; name=\"file\"; filename=\"meta\"\\r\\n\\r\\n[{\"action\": \"C\", \"name\": \"images\", \"parentoid\": \"165ca6f0c2300d8c\", \"isFile\": false, \"originalobjectpolicy\": \"(if (contains email \\\\\"hiromi.suenaga@greymatter.io\\\\\")(yield-all)(yield R X))\", \"security\": {\"label\": \"DECIPHER//GMDATA\", \"foreground\": \"#FFFFFF\", \"background\": \"green\"}}]\\r\\n--4d89249fa31cb8fa11b85fb3d5069385--\\r\\n'\n2021-01-22 14:11:59,803 - pygmdata - DEBUG - Headers: {'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'USER_DN': 'CN=hiromi.suenaga,OU=Engineering,O=Decipher Technology Studios,L=Alexandria,ST=Virginia,C=US', 'Content-Length': '420', 'Content-Type': 'multipart/form-data; boundary=4d89249fa31cb8fa11b85fb3d5069385'}\n2021-01-22 14:11:59,804 - pygmdata - DEBUG - Response\n2021-01-22 14:11:59,804 - pygmdata - DEBUG - 200\n2021-01-22 14:11:59,805 - pygmdata - DEBUG - [{'tstamp': '165ca6f0cab31080', 'userpolicy': {'label': 'CN=hiromi.suenaga,OU=Engineering,O=Decipher Technology Studios,L=Alexandria,ST=Virginia,C=US'}, 'jwthash': 'dfdb11306b33079c43cd644aea4c2b976e4f97a089c7eb689ae5328b14d26ec8', 'schemaversion': 10, 'name': 'images', 'action': 'C', 'oid': '165ca6f0ca9aee60', 'parentoid': '165ca6f0c2300d8c', 'expiration': '7fffffffffffffff', 'checkedtstamp': '165ca6f0c243d920', 'objectpolicy': {'requirements': {'f': 'if', 'a': [{'f': 'contains', 'a': [{'v': 'email'}, {'v': 'hiromi.suenaga@greymatter.io'}]}, {'f': 'yield-all'}, {'f': 'yield', 'a': [{'v': 'R'}, {'v': 'X'}]}]}}, 'derived': {}, 'security': {'label': 'DECIPHER//GMDATA', 'foreground': '#FFFFFF', 'background': 'green'}, 'originalobjectpolicy': '(if (contains email \"hiromi.suenaga@greymatter.io\")(yield-all)(yield R X))', 'cluster': 'default'}]\n"
},
{
"data": {
"text/plain": "'165ca6f0ca9aee60'"
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "data.make_directory_tree('/')",
"execution_count": 6,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": "2021-01-22 14:12:01,895 - pygmdata - DEBUG - path: /world, oid: 1\n2021-01-22 14:12:01,937 - pygmdata - DEBUG - path: /world/hiromi.suenaga@greymatter.io, oid: 165c9f359d6082ec\n2021-01-22 14:12:01,971 - pygmdata - DEBUG - path: /world/hiromi.suenaga@greymatter.io/images, oid: 165ca6f0c2300d8c\n2021-01-22 14:12:02,004 - pygmdata - DEBUG - Looking for /, oid None\n"
},
{
"ename": "Exception",
"evalue": "Unable to locate the root directory",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-6-6f7996915a52>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmake_directory_tree\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'/'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m~/git/pygmdata/pygmdata/pygmdata.py\u001b[0m in \u001b[0;36mmake_directory_tree\u001b[0;34m(self, path, lisp_object_policy, **kwargs)\u001b[0m\n\u001b[1;32m 265\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0moid\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 266\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mroot\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 267\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Unable to locate the root directory'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 268\u001b[0m self.log.debug(\"Path {} not found, creating\"\n\u001b[1;32m 269\u001b[0m \" parent\".format(path.parent))\n",
"\u001b[0;31mException\u001b[0m: Unable to locate the root directory"
]
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "data.make_directory_tree('/home')",
"execution_count": 7,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": "2021-01-22 14:12:04,005 - pygmdata - DEBUG - path: /world, oid: 1\n2021-01-22 14:12:04,041 - pygmdata - DEBUG - path: /world/hiromi.suenaga@greymatter.io, oid: 165c9f359d6082ec\n2021-01-22 14:12:04,077 - pygmdata - DEBUG - path: /world/hiromi.suenaga@greymatter.io/images, oid: 165ca6f0c2300d8c\n2021-01-22 14:12:04,110 - pygmdata - DEBUG - Looking for /, oid None\n2021-01-22 14:12:04,111 - pygmdata - DEBUG - Path / not found, creating parent\n2021-01-22 14:12:04,145 - pygmdata - DEBUG - path: /world, oid: 1\n2021-01-22 14:12:04,178 - pygmdata - DEBUG - path: /world/hiromi.suenaga@greymatter.io, oid: 165c9f359d6082ec\n2021-01-22 14:12:04,212 - pygmdata - DEBUG - path: /world/hiromi.suenaga@greymatter.io/images, oid: 165ca6f0c2300d8c\n2021-01-22 14:12:04,246 - pygmdata - DEBUG - Looking for /, oid None\n"
},
{
"ename": "Exception",
"evalue": "Unable to locate the root directory",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-7-834ae586f551>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmake_directory_tree\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'/home'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m~/git/pygmdata/pygmdata/pygmdata.py\u001b[0m in \u001b[0;36mmake_directory_tree\u001b[0;34m(self, path, lisp_object_policy, **kwargs)\u001b[0m\n\u001b[1;32m 268\u001b[0m self.log.debug(\"Path {} not found, creating\"\n\u001b[1;32m 269\u001b[0m \" parent\".format(path.parent))\n\u001b[0;32m--> 270\u001b[0;31m self.make_directory_tree(str(path.parent),\n\u001b[0m\u001b[1;32m 271\u001b[0m \u001b[0mlisp_object_policy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlisp_object_policy\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 272\u001b[0m **kwargs)\n",
"\u001b[0;32m~/git/pygmdata/pygmdata/pygmdata.py\u001b[0m in \u001b[0;36mmake_directory_tree\u001b[0;34m(self, path, lisp_object_policy, **kwargs)\u001b[0m\n\u001b[1;32m 265\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0moid\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 266\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mroot\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 267\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Unable to locate the root directory'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 268\u001b[0m self.log.debug(\"Path {} not found, creating\"\n\u001b[1;32m 269\u001b[0m \" parent\".format(path.parent))\n",
"\u001b[0;31mException\u001b[0m: Unable to locate the root directory"
]
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"gist": {
"id": "",
"data": {
"description": "docs/test.ipynb",
"public": true
}
},
"kernelspec": {
"name": "fracking",
"display_name": "fracking",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.8.5",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"toc": {
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": false,
"base_numbering": 1,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {
"height": "calc(100% - 180px)",
"left": "10px",
"top": "150px",
"width": "469.391px"
},
"toc_section_display": true,
"toc_window_display": true
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment