This commit is contained in:
ahmadbilalkhalid 2019-09-17 22:20:10 +05:00
parent c82cc428ed
commit 0e5def8ab7
3 changed files with 22 additions and 58 deletions

View file

@ -7,7 +7,6 @@ verify_ssl = true
[packages] [packages]
python-decouple = "*" python-decouple = "*"
xattr = "*"
python-etcd3 = {editable = true,git = "https://github.com/kragniz/python-etcd3.git"} python-etcd3 = {editable = true,git = "https://github.com/kragniz/python-etcd3.git"}
etcd3-wrapper = {editable = true,git = "https://code.ungleich.ch/ungleich-public/etcd3_wrapper.git",ref = "wip"} etcd3-wrapper = {editable = true,git = "https://code.ungleich.ch/ungleich-public/etcd3_wrapper.git",ref = "wip"}
ucloud-common = {editable = true,git = "https://code.ungleich.ch/ucloud/ucloud_common.git",ref = "wip"} ucloud-common = {editable = true,git = "https://code.ungleich.ch/ucloud/ucloud_common.git",ref = "wip"}

53
Pipfile.lock generated
View file

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "bb1c563b5ae54f6e0ffd6e174485bd4ba2b7616c15371da75947d6198ec1878e" "sha256": "a4e768bcbf48b95824887d9825cd00e2eb689c9e03c154cc123fb1d472c8d00c"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
@ -16,43 +16,10 @@
] ]
}, },
"default": { "default": {
"cffi": {
"hashes": [
"sha256:041c81822e9f84b1d9c401182e174996f0bae9991f33725d059b771744290774",
"sha256:046ef9a22f5d3eed06334d01b1e836977eeef500d9b78e9ef693f9380ad0b83d",
"sha256:066bc4c7895c91812eff46f4b1c285220947d4aa46fa0a2651ff85f2afae9c90",
"sha256:066c7ff148ae33040c01058662d6752fd73fbc8e64787229ea8498c7d7f4041b",
"sha256:2444d0c61f03dcd26dbf7600cf64354376ee579acad77aef459e34efcb438c63",
"sha256:300832850b8f7967e278870c5d51e3819b9aad8f0a2c8dbe39ab11f119237f45",
"sha256:34c77afe85b6b9e967bd8154e3855e847b70ca42043db6ad17f26899a3df1b25",
"sha256:46de5fa00f7ac09f020729148ff632819649b3e05a007d286242c4882f7b1dc3",
"sha256:4aa8ee7ba27c472d429b980c51e714a24f47ca296d53f4d7868075b175866f4b",
"sha256:4d0004eb4351e35ed950c14c11e734182591465a33e960a4ab5e8d4f04d72647",
"sha256:4e3d3f31a1e202b0f5a35ba3bc4eb41e2fc2b11c1eff38b362de710bcffb5016",
"sha256:50bec6d35e6b1aaeb17f7c4e2b9374ebf95a8975d57863546fa83e8d31bdb8c4",
"sha256:55cad9a6df1e2a1d62063f79d0881a414a906a6962bc160ac968cc03ed3efcfb",
"sha256:5662ad4e4e84f1eaa8efce5da695c5d2e229c563f9d5ce5b0113f71321bcf753",
"sha256:59b4dc008f98fc6ee2bb4fd7fc786a8d70000d058c2bbe2698275bc53a8d3fa7",
"sha256:73e1ffefe05e4ccd7bcea61af76f36077b914f92b76f95ccf00b0c1b9186f3f9",
"sha256:a1f0fd46eba2d71ce1589f7e50a9e2ffaeb739fb2c11e8192aa2b45d5f6cc41f",
"sha256:a2e85dc204556657661051ff4bab75a84e968669765c8a2cd425918699c3d0e8",
"sha256:a5457d47dfff24882a21492e5815f891c0ca35fefae8aa742c6c263dac16ef1f",
"sha256:a8dccd61d52a8dae4a825cdbb7735da530179fea472903eb871a5513b5abbfdc",
"sha256:ae61af521ed676cf16ae94f30fe202781a38d7178b6b4ab622e4eec8cefaff42",
"sha256:b012a5edb48288f77a63dba0840c92d0504aa215612da4541b7b42d849bc83a3",
"sha256:d2c5cfa536227f57f97c92ac30c8109688ace8fa4ac086d19d0af47d134e2909",
"sha256:d42b5796e20aacc9d15e66befb7a345454eef794fdb0737d1af593447c6c8f45",
"sha256:dee54f5d30d775f525894d67b1495625dd9322945e7fee00731952e0368ff42d",
"sha256:e070535507bd6aa07124258171be2ee8dfc19119c28ca94c9dfb7efd23564512",
"sha256:e1ff2748c84d97b065cc95429814cdba39bcbd77c9c85c89344b317dc0d9cbff",
"sha256:ed851c75d1e0e043cbf5ca9a8e1b13c4c90f3fbd863dacb01c0808e2b5204201"
],
"version": "==1.12.3"
},
"etcd3-wrapper": { "etcd3-wrapper": {
"editable": true, "editable": true,
"git": "https://code.ungleich.ch/ungleich-public/etcd3_wrapper.git", "git": "https://code.ungleich.ch/ungleich-public/etcd3_wrapper.git",
"ref": "b1893fc286e9ed59876a526d81094edd796d6815" "ref": "24c53ba969bda8d58e38373310eb41914dd566fd"
}, },
"grpcio": { "grpcio": {
"hashes": [ "hashes": [
@ -112,12 +79,6 @@
], ],
"version": "==3.9.1" "version": "==3.9.1"
}, },
"pycparser": {
"hashes": [
"sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3"
],
"version": "==2.19"
},
"python-decouple": { "python-decouple": {
"hashes": [ "hashes": [
"sha256:1317df14b43efee4337a4aa02914bf004f010cd56d6c4bd894e6474ec8c4fe2d" "sha256:1317df14b43efee4337a4aa02914bf004f010cd56d6c4bd894e6474ec8c4fe2d"
@ -148,16 +109,6 @@
"editable": true, "editable": true,
"git": "https://code.ungleich.ch/ucloud/ucloud_common.git", "git": "https://code.ungleich.ch/ucloud/ucloud_common.git",
"ref": "0976a3e2ef648564483e69e89a530f55be630e08" "ref": "0976a3e2ef648564483e69e89a530f55be630e08"
},
"xattr": {
"hashes": [
"sha256:117f864caf6428a75ed1263d29e020afb5db30dcbdfc1b79da9f19ec8748d2df",
"sha256:4ea01c6d23252d9caeae613ea63191095924ec14df3a9390a404e84df6a1ddb7",
"sha256:7cb1b28eeab4fe99cc4350e831434142fce658f7d03f173ff7722144e6a47458",
"sha256:c0a5ec84ec3b98f0082cf3bafd299f2fa89a4e54ae4b0b1d6fab5ceea3d0d37a"
],
"index": "pypi",
"version": "==0.9.6"
} }
}, },
"develop": {} "develop": {}

26
main.py
View file

@ -1,20 +1,34 @@
import os import os
import glob import glob
import xattr
import pathlib import pathlib
import time import time
import hashlib import hashlib
import subprocess as sp
from decouple import config from decouple import config
from etcd3_wrapper import Etcd3Wrapper from etcd3_wrapper import Etcd3Wrapper
from uuid import uuid4 from uuid import uuid4
def getxattr(f, attr, symlink=False):
def getxattr(file, attr):
try: try:
return xattr.getxattr(f, attr, symlink).decode("utf-8") attr = "user." + attr
except OSError as _: value = sp.check_output(['getfattr', file,
return None '--name', attr,
'--only-values',
'--absolute-names'])
value = value.decode("utf-8")
except sp.CalledProcessError:
value = None
return value
def setxattr(file, attr, value):
attr = "user." + attr
sp.check_output(['setfattr', file,
'--name', attr,
'--value', str(value)])
def sha512sum(filename): def sha512sum(filename):
@ -83,4 +97,4 @@ for file in untracked_files:
print("Tracking {}".format(file)) print("Tracking {}".format(file))
# Insert Entry # Insert Entry
etcd_client.put(entry_key, entry_value, value_in_json=True) etcd_client.put(entry_key, entry_value, value_in_json=True)
xattr.setxattr(file, b"user.utracked", b"True") setxattr(file, "user.utracked", True)