GitHub PullRequestReviewCommentEvent at 2014-07-08 15:05:16
Repository: cvmfs
Actor: DrDaveD
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/cvmfs/cvmfs/pulls/comments/14657834","id":14657834,"diff_hunk":"@@ -0,0 +1,120 @@\n+import math\n+import string\n+import re\n+import bisect\n+import cvmfs_api\n+\n+import GeoIP\n+\n+gi = GeoIP.open(\"/var/lib/cvmfs-server/geo/GeoLiteCity.dat\", GeoIP.GEOIP_STANDARD)\n+\n+positive_expire_secs = 60*60*24*3  # 3 days\n+\n+# function came from http://www.johndcook.com/python_longitude_latitude.html\n+def distance_on_unit_sphere(lat1, long1, lat2, long2):\n+\n+    if (lat1 == lat2) and (long1 == long2):\n+\treturn 0.0\n+\n+    # Convert latitude and longitude to \n+    # spherical coordinates in radians.\n+    degrees_to_radians = math.pi/180.0\n+\t\n+    # phi = 90 - latitude\n+    phi1 = (90.0 - lat1)*degrees_to_radians\n+    phi2 = (90.0 - lat2)*degrees_to_radians\n+\t\n+    # theta = longitude\n+    theta1 = long1*degrees_to_radians\n+    theta2 = long2*degrees_to_radians\n+\t\n+    # Compute spherical distance from spherical coordinates.\n+\t\n+    # For two locations in spherical coordinates \n+    # (1, theta, phi) and (1, theta, phi)\n+    # cosine( arc length ) = \n+    #    sin phi sin phi' cos(theta-theta') + cos phi cos phi'\n+    # distance = rho * arc length\n+    \n+    cos = (math.sin(phi1)*math.sin(phi2)*math.cos(theta1 - theta2) + \n+           math.cos(phi1)*math.cos(phi2))\n+    arc = math.acos( cos )\n+\n+    # Remember to multiply arc by the radius of the earth \n+    # in your favorite set of units to get length.\n+    return arc\n+\n+\n+# Pattern including all allowed characters in addresses.\n+# The geoip api functions will further validate, but for paranoia's sake\n+#   (because I'm not sure how good the functions' error checking is), make\n+#   sure the names are limited to valid hostname characters.\n+# Include ':' for IPv6 addresses.\n+addr_pattern = re.compile('^[0-9a-zA-Z.:-]*$')\n+\n+def api(path_info, repo_name, version, start_response, environ):","path":"cvmfs/webapi/cvmfs_geo.py","position":null,"original_position":55,"commit_id":"6c4c8c0560339cb35e396acd62229ffe480e1b20","original_commit_id":"c4fd8ad3619c91ee3f5c389588b22584feac5117","user":{"login":"DrDaveD","id":2129743,"avatar_url":"https://avatars.githubusercontent.com/u/2129743?","gravatar_id":"b6711ca272f4648f7bd67167e7f07dd3","url":"https://api.github.com/users/DrDaveD","html_url":"https://github.com/DrDaveD","followers_url":"https://api.github.com/users/DrDaveD/followers","following_url":"https://api.github.com/users/DrDaveD/following{/other_user}","gists_url":"https://api.github.com/users/DrDaveD/gists{/gist_id}","starred_url":"https://api.github.com/users/DrDaveD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrDaveD/subscriptions","organizations_url":"https://api.github.com/users/DrDaveD/orgs","repos_url":"https://api.github.com/users/DrDaveD/repos","events_url":"https://api.github.com/users/DrDaveD/events{/privacy}","received_events_url":"https://api.github.com/users/DrDaveD/received_events","type":"User","site_admin":false},"body":"Pushed.","created_at":"2014-07-08T15:05:16Z","updated_at":"2014-07-08T15:05:16Z","html_url":"https://github.com/cvmfs/cvmfs/pull/479#discussion_r14657834","pull_request_url":"https://api.github.com/repos/cvmfs/cvmfs/pulls/479","_links":{"self":{"href":"https://api.github.com/repos/cvmfs/cvmfs/pulls/comments/14657834"},"html":{"href":"https://github.com/cvmfs/cvmfs/pull/479#discussion_r14657834"},"pull_request":{"href":"https://api.github.com/repos/cvmfs/cvmfs/pulls/479"}}},"pull_request":{"url":"https://api.github.com/repos/cvmfs/cvmfs/pulls/479","id":16563169,"html_url":"https://github.com/cvmfs/cvmfs/pull/479","diff_url":"https://github.com/cvmfs/cvmfs/pull/479.diff","patch_url":"https://github.com/cvmfs/cvmfs/pull/479.patch","issue_url":"https://api.github.com/repos/cvmfs/cvmfs/issues/479","number":479,"state":"open","title":"Add geo api to cvmfs-server","user":{"login":"DrDaveD","id":2129743,"avatar_url":"https://avatars.githubusercontent.com/u/2129743?","gravatar_id":"b6711ca272f4648f7bd67167e7f07dd3","url":"https://api.github.com/users/DrDaveD","html_url":"https://github.com/DrDaveD","followers_url":"https://api.github.com/users/DrDaveD/followers","following_url":"https://api.github.com/users/DrDaveD/following{/other_user}","gists_url":"https://api.github.com/users/DrDaveD/gists{/gist_id}","starred_url":"https://api.github.com/users/DrDaveD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrDaveD/subscriptions","organizations_url":"https://api.github.com/users/DrDaveD/orgs","repos_url":"https://api.github.com/users/DrDaveD/repos","events_url":"https://api.github.com/users/DrDaveD/events{/privacy}","received_events_url":"https://api.github.com/users/DrDaveD/received_events","type":"User","site_admin":false},"body":"This request adds the geo api.  It doesn't yet include any documentation, and I haven't written automated tests.  I have tested the rpm creation, and guessed at the debian configuration changes but didn't test them because I haven't yet learned to build debian packages.   Below are the configuration additions needed in a /etc/httpd/conf.d configuration file.  It also requires the mod_wsgi package for this to work.  I'm not entirely sure where to document that yet beyond the tech report.  Perhaps it could go in the apache config created by cvmfs_server snapshot, but probably commented out because not everybody will use it.\r\n\r\n```\r\nRewriteEngine on\r\n\r\n# Change api calls to /cvmfs-api internally where it can be easily\r\n#   caught by the WSGIScriptAlias below\r\nRewriteRule ^/cvmfs/([^/]+)/api/(.*)$ /cvmfs-api/$1/$2 [PT]\r\n\r\n# Enable the api functions\r\nLoadModule wsgi_module modules/mod_wsgi.so\r\nWSGIDaemonProcess cvmfs-api processes=2 display-name=%{GROUP} \\\r\n        python-path=/usr/share/cvmfs-server/webapi\r\nWSGIProcessGroup cvmfs-api\r\nWSGISocketPrefix /var/run/wsgi\r\nWSGIScriptAlias /cvmfs-api /var/www/wsgi-scripts/cvmfs-api.wsgi\r\n\r\n<Directory /usr/www/wsgi-scripts>\r\n    Order allow,deny\r\n    Allow from all\r\n</Directory>\r\n```\r\n","created_at":"2014-05-31T03:12:06Z","updated_at":"2014-07-08T15:05:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"772e123c77c4730efae2d169de1997a710c4a06d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cvmfs/cvmfs/pulls/479/commits","review_comments_url":"https://api.github.com/repos/cvmfs/cvmfs/pulls/479/comments","review_comment_url":"https://api.github.com/repos/cvmfs/cvmfs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/cvmfs/cvmfs/issues/479/comments","statuses_url":"https://api.github.com/repos/cvmfs/cvmfs/statuses/6c4c8c0560339cb35e396acd62229ffe480e1b20","head":{"label":"DrDaveD:devel","ref":"devel","sha":"6c4c8c0560339cb35e396acd62229ffe480e1b20","user":{"login":"DrDaveD","id":2129743,"avatar_url":"https://avatars.githubusercontent.com/u/2129743?","gravatar_id":"b6711ca272f4648f7bd67167e7f07dd3","url":"https://api.github.com/users/DrDaveD","html_url":"https://github.com/DrDaveD","followers_url":"https://api.github.com/users/DrDaveD/followers","following_url":"https://api.github.com/users/DrDaveD/following{/other_user}","gists_url":"https://api.github.com/users/DrDaveD/gists{/gist_id}","starred_url":"https://api.github.com/users/DrDaveD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrDaveD/subscriptions","organizations_url":"https://api.github.com/users/DrDaveD/orgs","repos_url":"https://api.github.com/users/DrDaveD/repos","events_url":"https://api.github.com/users/DrDaveD/events{/privacy}","received_events_url":"https://api.github.com/users/DrDaveD/received_events","type":"User","site_admin":false},"repo":{"id":11373318,"name":"cvmfs","full_name":"DrDaveD/cvmfs","owner":{"login":"DrDaveD","id":2129743,"avatar_url":"https://avatars.githubusercontent.com/u/2129743?","gravatar_id":"b6711ca272f4648f7bd67167e7f07dd3","url":"https://api.github.com/users/DrDaveD","html_url":"https://github.com/DrDaveD","followers_url":"https://api.github.com/users/DrDaveD/followers","following_url":"https://api.github.com/users/DrDaveD/following{/other_user}","gists_url":"https://api.github.com/users/DrDaveD/gists{/gist_id}","starred_url":"https://api.github.com/users/DrDaveD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrDaveD/subscriptions","organizations_url":"https://api.github.com/users/DrDaveD/orgs","repos_url":"https://api.github.com/users/DrDaveD/repos","events_url":"https://api.github.com/users/DrDaveD/events{/privacy}","received_events_url":"https://api.github.com/users/DrDaveD/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DrDaveD/cvmfs","description":"The CernVM File System","fork":true,"url":"https://api.github.com/repos/DrDaveD/cvmfs","forks_url":"https://api.github.com/repos/DrDaveD/cvmfs/forks","keys_url":"https://api.github.com/repos/DrDaveD/cvmfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DrDaveD/cvmfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DrDaveD/cvmfs/teams","hooks_url":"https://api.github.com/repos/DrDaveD/cvmfs/hooks","issue_events_url":"https://api.github.com/repos/DrDaveD/cvmfs/issues/events{/number}","events_url":"https://api.github.com/repos/DrDaveD/cvmfs/events","assignees_url":"https://api.github.com/repos/DrDaveD/cvmfs/assignees{/user}","branches_url":"https://api.github.com/repos/DrDaveD/cvmfs/branches{/branch}","tags_url":"https://api.github.com/repos/DrDaveD/cvmfs/tags","blobs_url":"https://api.github.com/repos/DrDaveD/cvmfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DrDaveD/cvmfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DrDaveD/cvmfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/DrDaveD/cvmfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DrDaveD/cvmfs/statuses/{sha}","languages_url":"https://api.github.com/repos/DrDaveD/cvmfs/languages","stargazers_url":"https://api.github.com/repos/DrDaveD/cvmfs/stargazers","contributors_url":"https://api.github.com/repos/DrDaveD/cvmfs/contributors","subscribers_url":"https://api.github.com/repos/DrDaveD/cvmfs/subscribers","subscription_url":"https://api.github.com/repos/DrDaveD/cvmfs/subscription","commits_url":"https://api.github.com/repos/DrDaveD/cvmfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/DrDaveD/cvmfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/DrDaveD/cvmfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/DrDaveD/cvmfs/issues/comments/{number}","contents_url":"https://api.github.com/repos/DrDaveD/cvmfs/contents/{+path}","compare_url":"https://api.github.com/repos/DrDaveD/cvmfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DrDaveD/cvmfs/merges","archive_url":"https://api.github.com/repos/DrDaveD/cvmfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DrDaveD/cvmfs/downloads","issues_url":"https://api.github.com/repos/DrDaveD/cvmfs/issues{/number}","pulls_url":"https://api.github.com/repos/DrDaveD/cvmfs/pulls{/number}","milestones_url":"https://api.github.com/repos/DrDaveD/cvmfs/milestones{/number}","notifications_url":"https://api.github.com/repos/DrDaveD/cvmfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DrDaveD/cvmfs/labels{/name}","releases_url":"https://api.github.com/repos/DrDaveD/cvmfs/releases{/id}","created_at":"2013-07-12T16:38:35Z","updated_at":"2014-07-07T19:31:21Z","pushed_at":"2014-07-08T15:05:07Z","git_url":"git://github.com/DrDaveD/cvmfs.git","ssh_url":"git@github.com:DrDaveD/cvmfs.git","clone_url":"https://github.com/DrDaveD/cvmfs.git","svn_url":"https://github.com/DrDaveD/cvmfs","homepage":"http://cernvm.cern.ch/portal/filesystem","size":77189,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"devel"}},"base":{"label":"cvmfs:devel","ref":"devel","sha":"1beab55040ef6f589c48e38275bae58880e1fd2e","user":{"login":"cvmfs","id":1560859,"avatar_url":"https://avatars.githubusercontent.com/u/1560859?","gravatar_id":null,"url":"https://api.github.com/users/cvmfs","html_url":"https://github.com/cvmfs","followers_url":"https://api.github.com/users/cvmfs/followers","following_url":"https://api.github.com/users/cvmfs/following{/other_user}","gists_url":"https://api.github.com/users/cvmfs/gists{/gist_id}","starred_url":"https://api.github.com/users/cvmfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cvmfs/subscriptions","organizations_url":"https://api.github.com/users/cvmfs/orgs","repos_url":"https://api.github.com/users/cvmfs/repos","events_url":"https://api.github.com/users/cvmfs/events{/privacy}","received_events_url":"https://api.github.com/users/cvmfs/received_events","type":"Organization","site_admin":false},"repo":{"id":3784908,"name":"cvmfs","full_name":"cvmfs/cvmfs","owner":{"login":"cvmfs","id":1560859,"avatar_url":"https://avatars.githubusercontent.com/u/1560859?","gravatar_id":null,"url":"https://api.github.com/users/cvmfs","html_url":"https://github.com/cvmfs","followers_url":"https://api.github.com/users/cvmfs/followers","following_url":"https://api.github.com/users/cvmfs/following{/other_user}","gists_url":"https://api.github.com/users/cvmfs/gists{/gist_id}","starred_url":"https://api.github.com/users/cvmfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cvmfs/subscriptions","organizations_url":"https://api.github.com/users/cvmfs/orgs","repos_url":"https://api.github.com/users/cvmfs/repos","events_url":"https://api.github.com/users/cvmfs/events{/privacy}","received_events_url":"https://api.github.com/users/cvmfs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cvmfs/cvmfs","description":"The CernVM File System","fork":false,"url":"https://api.github.com/repos/cvmfs/cvmfs","forks_url":"https://api.github.com/repos/cvmfs/cvmfs/forks","keys_url":"https://api.github.com/repos/cvmfs/cvmfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cvmfs/cvmfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cvmfs/cvmfs/teams","hooks_url":"https://api.github.com/repos/cvmfs/cvmfs/hooks","issue_events_url":"https://api.github.com/repos/cvmfs/cvmfs/issues/events{/number}","events_url":"https://api.github.com/repos/cvmfs/cvmfs/events","assignees_url":"https://api.github.com/repos/cvmfs/cvmfs/assignees{/user}","branches_url":"https://api.github.com/repos/cvmfs/cvmfs/branches{/branch}","tags_url":"https://api.github.com/repos/cvmfs/cvmfs/tags","blobs_url":"https://api.github.com/repos/cvmfs/cvmfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cvmfs/cvmfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cvmfs/cvmfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/cvmfs/cvmfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cvmfs/cvmfs/statuses/{sha}","languages_url":"https://api.github.com/repos/cvmfs/cvmfs/languages","stargazers_url":"https://api.github.com/repos/cvmfs/cvmfs/stargazers","contributors_url":"https://api.github.com/repos/cvmfs/cvmfs/contributors","subscribers_url":"https://api.github.com/repos/cvmfs/cvmfs/subscribers","subscription_url":"https://api.github.com/repos/cvmfs/cvmfs/subscription","commits_url":"https://api.github.com/repos/cvmfs/cvmfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/cvmfs/cvmfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/cvmfs/cvmfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/cvmfs/cvmfs/issues/comments/{number}","contents_url":"https://api.github.com/repos/cvmfs/cvmfs/contents/{+path}","compare_url":"https://api.github.com/repos/cvmfs/cvmfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cvmfs/cvmfs/merges","archive_url":"https://api.github.com/repos/cvmfs/cvmfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cvmfs/cvmfs/downloads","issues_url":"https://api.github.com/repos/cvmfs/cvmfs/issues{/number}","pulls_url":"https://api.github.com/repos/cvmfs/cvmfs/pulls{/number}","milestones_url":"https://api.github.com/repos/cvmfs/cvmfs/milestones{/number}","notifications_url":"https://api.github.com/repos/cvmfs/cvmfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cvmfs/cvmfs/labels{/name}","releases_url":"https://api.github.com/repos/cvmfs/cvmfs/releases{/id}","created_at":"2012-03-21T09:10:41Z","updated_at":"2014-06-26T19:08:20Z","pushed_at":"2014-07-07T17:55:54Z","git_url":"git://github.com/cvmfs/cvmfs.git","ssh_url":"git@github.com:cvmfs/cvmfs.git","clone_url":"https://github.com/cvmfs/cvmfs.git","svn_url":"https://github.com/cvmfs/cvmfs","homepage":"http://cernvm.cern.ch/portal/filesystem","size":84711,"stargazers_count":26,"watchers_count":26,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":22,"mirror_url":null,"open_issues_count":4,"forks":22,"open_issues":4,"watchers":26,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/cvmfs/cvmfs/pulls/479"},"html":{"href":"https://github.com/cvmfs/cvmfs/pull/479"},"issue":{"href":"https://api.github.com/repos/cvmfs/cvmfs/issues/479"},"comments":{"href":"https://api.github.com/repos/cvmfs/cvmfs/issues/479/comments"},"review_comments":{"href":"https://api.github.com/repos/cvmfs/cvmfs/pulls/479/comments"},"review_comment":{"href":"https://api.github.com/repos/cvmfs/cvmfs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/cvmfs/cvmfs/pulls/479/commits"},"statuses":{"href":"https://api.github.com/repos/cvmfs/cvmfs/statuses/6c4c8c0560339cb35e396acd62229ffe480e1b20"}}}}