{"action":"created","comment":{"url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/comments/80463537","id":80463537,"diff_hunk":"@@ -50,6 +50,39 @@\n MAX_STORAGE_SIZE = 0\n USE_TOKENS = False\n \n+def getDiskSpace(path, size = 'TB', total = False):\n+    \"\"\"\n+      Returns disk usage of the given path.\n+      If no size is specified, terabytes will be used by default.\n+      If total is set to true, the total disk space will be returned instead.\n+    \"\"\"\n+\n+    if size.upper() == \"KB\":\n+      convert = 1024\n+    elif size.upper() == \"MB\":\n+      convert = 1.048576e6\n+    elif size.upper() == \"GB\":\n+      convert = 1.073741824e9\n+    elif size.upper() == \"TB\":\n+      convert = 1.099511627776e12\n+    else:\n+      return S_ERROR( \"No valid size specified\" )\n+\n+    try:\n+      st = os.statvfs(path)\n+\n+      if total:\n+        # return total space\n+        result = (st.f_blocks * st.f_frsize) / convert\n+      else:\n+        # return free space\n+        result = (st.f_bavail * st.f_frsize) / convert\n+\n+    except OSError as e:\n+      return S_ERROR( \"Error %s\", e )","path":"DataManagementSystem/Service/StorageElementHandler.py","position":33,"original_position":33,"commit_id":"fac178313573f3cd58d81d47b437b00e2ccdbcbb","original_commit_id":"fac178313573f3cd58d81d47b437b00e2ccdbcbb","user":{"login":"fstagni","id":785576,"avatar_url":"https://avatars.githubusercontent.com/u/785576?v=3","gravatar_id":"","url":"https://api.github.com/users/fstagni","html_url":"https://github.com/fstagni","followers_url":"https://api.github.com/users/fstagni/followers","following_url":"https://api.github.com/users/fstagni/following{/other_user}","gists_url":"https://api.github.com/users/fstagni/gists{/gist_id}","starred_url":"https://api.github.com/users/fstagni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fstagni/subscriptions","organizations_url":"https://api.github.com/users/fstagni/orgs","repos_url":"https://api.github.com/users/fstagni/repos","events_url":"https://api.github.com/users/fstagni/events{/privacy}","received_events_url":"https://api.github.com/users/fstagni/received_events","type":"User","site_admin":false},"body":"do instead\r\n```\r\nreturn S_ERROR( errno.EIO, \"Error while getting the available disk space: %s\", repr(e) )\r\n```","created_at":"2016-09-26T12:28:48Z","updated_at":"2016-09-26T12:29:06Z","html_url":"https://github.com/DIRACGrid/DIRAC/pull/3099#discussion_r80463537","pull_request_url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/3099","_links":{"self":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/comments/80463537"},"html":{"href":"https://github.com/DIRACGrid/DIRAC/pull/3099#discussion_r80463537"},"pull_request":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/3099"}}},"pull_request":{"url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/3099","id":83983446,"html_url":"https://github.com/DIRACGrid/DIRAC/pull/3099","diff_url":"https://github.com/DIRACGrid/DIRAC/pull/3099.diff","patch_url":"https://github.com/DIRACGrid/DIRAC/pull/3099.patch","issue_url":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/3099","number":3099,"state":"open","locked":false,"title":"[WIP] [v6r16] Monitoring the space left on DIRAC SEs","user":{"login":"vipersec","id":8127545,"avatar_url":"https://avatars.githubusercontent.com/u/8127545?v=3","gravatar_id":"","url":"https://api.github.com/users/vipersec","html_url":"https://github.com/vipersec","followers_url":"https://api.github.com/users/vipersec/followers","following_url":"https://api.github.com/users/vipersec/following{/other_user}","gists_url":"https://api.github.com/users/vipersec/gists{/gist_id}","starred_url":"https://api.github.com/users/vipersec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vipersec/subscriptions","organizations_url":"https://api.github.com/users/vipersec/orgs","repos_url":"https://api.github.com/users/vipersec/repos","events_url":"https://api.github.com/users/vipersec/events{/privacy}","received_events_url":"https://api.github.com/users/vipersec/received_events","type":"User","site_admin":false},"body":"I have added a new command named `FreeDiskSpace` which is used to get the total and the remaining disk space of all dirac storage elements that are found in the CS and inserts the results in the `SpaceTokenOccupancyCache` table of `ResourceManagementDB` database.","created_at":"2016-09-05T10:44:08Z","updated_at":"2016-09-26T12:29:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c9af72deebf54805bb23e05c387a8177f3a5565","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/3099/commits","review_comments_url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/3099/comments","review_comment_url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/3099/comments","statuses_url":"https://api.github.com/repos/DIRACGrid/DIRAC/statuses/fac178313573f3cd58d81d47b437b00e2ccdbcbb","head":{"label":"vipersec:dips-space","ref":"dips-space","sha":"fac178313573f3cd58d81d47b437b00e2ccdbcbb","user":{"login":"vipersec","id":8127545,"avatar_url":"https://avatars.githubusercontent.com/u/8127545?v=3","gravatar_id":"","url":"https://api.github.com/users/vipersec","html_url":"https://github.com/vipersec","followers_url":"https://api.github.com/users/vipersec/followers","following_url":"https://api.github.com/users/vipersec/following{/other_user}","gists_url":"https://api.github.com/users/vipersec/gists{/gist_id}","starred_url":"https://api.github.com/users/vipersec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vipersec/subscriptions","organizations_url":"https://api.github.com/users/vipersec/orgs","repos_url":"https://api.github.com/users/vipersec/repos","events_url":"https://api.github.com/users/vipersec/events{/privacy}","received_events_url":"https://api.github.com/users/vipersec/received_events","type":"User","site_admin":false},"repo":{"id":51287138,"name":"DIRAC","full_name":"vipersec/DIRAC","owner":{"login":"vipersec","id":8127545,"avatar_url":"https://avatars.githubusercontent.com/u/8127545?v=3","gravatar_id":"","url":"https://api.github.com/users/vipersec","html_url":"https://github.com/vipersec","followers_url":"https://api.github.com/users/vipersec/followers","following_url":"https://api.github.com/users/vipersec/following{/other_user}","gists_url":"https://api.github.com/users/vipersec/gists{/gist_id}","starred_url":"https://api.github.com/users/vipersec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vipersec/subscriptions","organizations_url":"https://api.github.com/users/vipersec/orgs","repos_url":"https://api.github.com/users/vipersec/repos","events_url":"https://api.github.com/users/vipersec/events{/privacy}","received_events_url":"https://api.github.com/users/vipersec/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vipersec/DIRAC","description":"DIRAC Grid","fork":true,"url":"https://api.github.com/repos/vipersec/DIRAC","forks_url":"https://api.github.com/repos/vipersec/DIRAC/forks","keys_url":"https://api.github.com/repos/vipersec/DIRAC/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vipersec/DIRAC/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vipersec/DIRAC/teams","hooks_url":"https://api.github.com/repos/vipersec/DIRAC/hooks","issue_events_url":"https://api.github.com/repos/vipersec/DIRAC/issues/events{/number}","events_url":"https://api.github.com/repos/vipersec/DIRAC/events","assignees_url":"https://api.github.com/repos/vipersec/DIRAC/assignees{/user}","branches_url":"https://api.github.com/repos/vipersec/DIRAC/branches{/branch}","tags_url":"https://api.github.com/repos/vipersec/DIRAC/tags","blobs_url":"https://api.github.com/repos/vipersec/DIRAC/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vipersec/DIRAC/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vipersec/DIRAC/git/refs{/sha}","trees_url":"https://api.github.com/repos/vipersec/DIRAC/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vipersec/DIRAC/statuses/{sha}","languages_url":"https://api.github.com/repos/vipersec/DIRAC/languages","stargazers_url":"https://api.github.com/repos/vipersec/DIRAC/stargazers","contributors_url":"https://api.github.com/repos/vipersec/DIRAC/contributors","subscribers_url":"https://api.github.com/repos/vipersec/DIRAC/subscribers","subscription_url":"https://api.github.com/repos/vipersec/DIRAC/subscription","commits_url":"https://api.github.com/repos/vipersec/DIRAC/commits{/sha}","git_commits_url":"https://api.github.com/repos/vipersec/DIRAC/git/commits{/sha}","comments_url":"https://api.github.com/repos/vipersec/DIRAC/comments{/number}","issue_comment_url":"https://api.github.com/repos/vipersec/DIRAC/issues/comments{/number}","contents_url":"https://api.github.com/repos/vipersec/DIRAC/contents/{+path}","compare_url":"https://api.github.com/repos/vipersec/DIRAC/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vipersec/DIRAC/merges","archive_url":"https://api.github.com/repos/vipersec/DIRAC/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vipersec/DIRAC/downloads","issues_url":"https://api.github.com/repos/vipersec/DIRAC/issues{/number}","pulls_url":"https://api.github.com/repos/vipersec/DIRAC/pulls{/number}","milestones_url":"https://api.github.com/repos/vipersec/DIRAC/milestones{/number}","notifications_url":"https://api.github.com/repos/vipersec/DIRAC/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vipersec/DIRAC/labels{/name}","releases_url":"https://api.github.com/repos/vipersec/DIRAC/releases{/id}","deployments_url":"https://api.github.com/repos/vipersec/DIRAC/deployments","created_at":"2016-02-08T08:49:32Z","updated_at":"2016-08-10T09:16:22Z","pushed_at":"2016-09-26T12:05:12Z","git_url":"git://github.com/vipersec/DIRAC.git","ssh_url":"git@github.com:vipersec/DIRAC.git","clone_url":"https://github.com/vipersec/DIRAC.git","svn_url":"https://github.com/vipersec/DIRAC","homepage":"http://diracgrid.org","size":42659,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"integration"}},"base":{"label":"DIRACGrid:rel-v6r16","ref":"rel-v6r16","sha":"e3e1f901d8f38f8cbc8eac1d115ea656f49fe6e2","user":{"login":"DIRACGrid","id":694842,"avatar_url":"https://avatars.githubusercontent.com/u/694842?v=3","gravatar_id":"","url":"https://api.github.com/users/DIRACGrid","html_url":"https://github.com/DIRACGrid","followers_url":"https://api.github.com/users/DIRACGrid/followers","following_url":"https://api.github.com/users/DIRACGrid/following{/other_user}","gists_url":"https://api.github.com/users/DIRACGrid/gists{/gist_id}","starred_url":"https://api.github.com/users/DIRACGrid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DIRACGrid/subscriptions","organizations_url":"https://api.github.com/users/DIRACGrid/orgs","repos_url":"https://api.github.com/users/DIRACGrid/repos","events_url":"https://api.github.com/users/DIRACGrid/events{/privacy}","received_events_url":"https://api.github.com/users/DIRACGrid/received_events","type":"Organization","site_admin":false},"repo":{"id":1576831,"name":"DIRAC","full_name":"DIRACGrid/DIRAC","owner":{"login":"DIRACGrid","id":694842,"avatar_url":"https://avatars.githubusercontent.com/u/694842?v=3","gravatar_id":"","url":"https://api.github.com/users/DIRACGrid","html_url":"https://github.com/DIRACGrid","followers_url":"https://api.github.com/users/DIRACGrid/followers","following_url":"https://api.github.com/users/DIRACGrid/following{/other_user}","gists_url":"https://api.github.com/users/DIRACGrid/gists{/gist_id}","starred_url":"https://api.github.com/users/DIRACGrid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DIRACGrid/subscriptions","organizations_url":"https://api.github.com/users/DIRACGrid/orgs","repos_url":"https://api.github.com/users/DIRACGrid/repos","events_url":"https://api.github.com/users/DIRACGrid/events{/privacy}","received_events_url":"https://api.github.com/users/DIRACGrid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DIRACGrid/DIRAC","description":"DIRAC Grid","fork":false,"url":"https://api.github.com/repos/DIRACGrid/DIRAC","forks_url":"https://api.github.com/repos/DIRACGrid/DIRAC/forks","keys_url":"https://api.github.com/repos/DIRACGrid/DIRAC/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DIRACGrid/DIRAC/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DIRACGrid/DIRAC/teams","hooks_url":"https://api.github.com/repos/DIRACGrid/DIRAC/hooks","issue_events_url":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/events{/number}","events_url":"https://api.github.com/repos/DIRACGrid/DIRAC/events","assignees_url":"https://api.github.com/repos/DIRACGrid/DIRAC/assignees{/user}","branches_url":"https://api.github.com/repos/DIRACGrid/DIRAC/branches{/branch}","tags_url":"https://api.github.com/repos/DIRACGrid/DIRAC/tags","blobs_url":"https://api.github.com/repos/DIRACGrid/DIRAC/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DIRACGrid/DIRAC/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DIRACGrid/DIRAC/git/refs{/sha}","trees_url":"https://api.github.com/repos/DIRACGrid/DIRAC/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DIRACGrid/DIRAC/statuses/{sha}","languages_url":"https://api.github.com/repos/DIRACGrid/DIRAC/languages","stargazers_url":"https://api.github.com/repos/DIRACGrid/DIRAC/stargazers","contributors_url":"https://api.github.com/repos/DIRACGrid/DIRAC/contributors","subscribers_url":"https://api.github.com/repos/DIRACGrid/DIRAC/subscribers","subscription_url":"https://api.github.com/repos/DIRACGrid/DIRAC/subscription","commits_url":"https://api.github.com/repos/DIRACGrid/DIRAC/commits{/sha}","git_commits_url":"https://api.github.com/repos/DIRACGrid/DIRAC/git/commits{/sha}","comments_url":"https://api.github.com/repos/DIRACGrid/DIRAC/comments{/number}","issue_comment_url":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/comments{/number}","contents_url":"https://api.github.com/repos/DIRACGrid/DIRAC/contents/{+path}","compare_url":"https://api.github.com/repos/DIRACGrid/DIRAC/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DIRACGrid/DIRAC/merges","archive_url":"https://api.github.com/repos/DIRACGrid/DIRAC/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DIRACGrid/DIRAC/downloads","issues_url":"https://api.github.com/repos/DIRACGrid/DIRAC/issues{/number}","pulls_url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls{/number}","milestones_url":"https://api.github.com/repos/DIRACGrid/DIRAC/milestones{/number}","notifications_url":"https://api.github.com/repos/DIRACGrid/DIRAC/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DIRACGrid/DIRAC/labels{/name}","releases_url":"https://api.github.com/repos/DIRACGrid/DIRAC/releases{/id}","deployments_url":"https://api.github.com/repos/DIRACGrid/DIRAC/deployments","created_at":"2011-04-06T11:47:53Z","updated_at":"2016-08-31T21:54:07Z","pushed_at":"2016-09-26T12:05:12Z","git_url":"git://github.com/DIRACGrid/DIRAC.git","ssh_url":"git@github.com:DIRACGrid/DIRAC.git","clone_url":"https://github.com/DIRACGrid/DIRAC.git","svn_url":"https://github.com/DIRACGrid/DIRAC","homepage":"http://diracgrid.org","size":62048,"stargazers_count":52,"watchers_count":52,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":97,"mirror_url":null,"open_issues_count":96,"forks":97,"open_issues":96,"watchers":52,"default_branch":"integration"}},"_links":{"self":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/3099"},"html":{"href":"https://github.com/DIRACGrid/DIRAC/pull/3099"},"issue":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/3099"},"comments":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/3099/comments"},"review_comments":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/3099/comments"},"review_comment":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/3099/commits"},"statuses":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/statuses/fac178313573f3cd58d81d47b437b00e2ccdbcbb"}}}}
{"actor":{"display_login":"fstagni"}}