{"action":"created","comment":{"url":"https://api.github.com/repos/ARM-software/devlib/pulls/comments/45713949","id":45713949,"diff_hunk":"@@ -0,0 +1,108 @@\n+#    Copyright 2015 ARM Limited\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+import logging\n+import re\n+\n+from devlib.module import Module\n+\n+class TripPoint(object):\n+    def __init__(self, zone, _id):\n+        self._id = _id\n+        self.zone = zone\n+        self.temp_node = 'trip_point_' + _id + '_temp'\n+        self.type_node = 'trip_point_' + _id + '_type'\n+\n+    def get_temperature(self):\n+        \"\"\"Returns the currently configured temperature of the trip point\"\"\"\n+        temp_file = self.zone.target.path.join(self.zone.path, self.temp_node)\n+        return self.zone.target.read_value(temp_file)\n+\n+    def set_temperature(self, temperature):\n+        temp_file = self.zone.target.path.join(self.zone.path, self.temp_node)\n+        self.zone.target_write_value(temp_file, temperature)\n+\n+    def get_type(self):\n+        \"\"\"Returns the type of trip point\"\"\"\n+        type_file = self.zone.target.path.join(self.zone.path, self.type_node)\n+        return self.zone.target.read_value(type_file)\n+\n+class ThermalZone(object):\n+    def __init__(self, target, root, _id):\n+        self.target = target\n+        self.name = 'thermal_zone' + _id\n+        self.path = target.path.join(root, self.name)\n+        self.trip_points = {}\n+\n+        for entry in self.target.list_directory(self.path):\n+            re_match = re.match('^trip_point_([0-9]+)_temp', entry)\n+            if re_match is not None:\n+                self.trip_point(re_match.group(1))\n+\n+    def trip_point(self, _id):\n+        self.trip_points[int(_id)] = TripPoint(self, _id)\n+\n+    def is_enabled(self):\n+        \"\"\"Returns a boolean representing the 'mode' of the thermal zone\"\"\"\n+        value = self.target.read_value(self.target.path.join(self.path, 'mode'))\n+        if value == 'enabled':\n+            return True\n+        else:\n+            return False","path":"devlib/module/thermal.py","position":62,"original_position":62,"commit_id":"bce6ebbd5c8053f1fb255ba63ee82b009dfca3cf","original_commit_id":"bce6ebbd5c8053f1fb255ba63ee82b009dfca3cf","user":{"login":"setrofim","id":904685,"avatar_url":"https://avatars.githubusercontent.com/u/904685?v=3","gravatar_id":"","url":"https://api.github.com/users/setrofim","html_url":"https://github.com/setrofim","followers_url":"https://api.github.com/users/setrofim/followers","following_url":"https://api.github.com/users/setrofim/following{/other_user}","gists_url":"https://api.github.com/users/setrofim/gists{/gist_id}","starred_url":"https://api.github.com/users/setrofim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/setrofim/subscriptions","organizations_url":"https://api.github.com/users/setrofim/orgs","repos_url":"https://api.github.com/users/setrofim/repos","events_url":"https://api.github.com/users/setrofim/events{/privacy}","received_events_url":"https://api.github.com/users/setrofim/received_events","type":"User","site_admin":false},"body":"Could be just\r\n\r\n      return value == 'enabled'","created_at":"2015-11-24T09:45:19Z","updated_at":"2015-11-24T09:45:19Z","html_url":"https://github.com/ARM-software/devlib/pull/5#discussion_r45713949","pull_request_url":"https://api.github.com/repos/ARM-software/devlib/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/ARM-software/devlib/pulls/comments/45713949"},"html":{"href":"https://github.com/ARM-software/devlib/pull/5#discussion_r45713949"},"pull_request":{"href":"https://api.github.com/repos/ARM-software/devlib/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/ARM-software/devlib/pulls/5","id":51518055,"html_url":"https://github.com/ARM-software/devlib/pull/5","diff_url":"https://github.com/ARM-software/devlib/pull/5.diff","patch_url":"https://github.com/ARM-software/devlib/pull/5.patch","issue_url":"https://api.github.com/repos/ARM-software/devlib/issues/5","number":5,"state":"open","locked":false,"title":"module: Add thermal support","user":{"login":"punitagrawal","id":790730,"avatar_url":"https://avatars.githubusercontent.com/u/790730?v=3","gravatar_id":"","url":"https://api.github.com/users/punitagrawal","html_url":"https://github.com/punitagrawal","followers_url":"https://api.github.com/users/punitagrawal/followers","following_url":"https://api.github.com/users/punitagrawal/following{/other_user}","gists_url":"https://api.github.com/users/punitagrawal/gists{/gist_id}","starred_url":"https://api.github.com/users/punitagrawal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/punitagrawal/subscriptions","organizations_url":"https://api.github.com/users/punitagrawal/orgs","repos_url":"https://api.github.com/users/punitagrawal/repos","events_url":"https://api.github.com/users/punitagrawal/events{/privacy}","received_events_url":"https://api.github.com/users/punitagrawal/received_events","type":"User","site_admin":false},"body":"Add a thermal module that will allow querying for thermal zones and trip\r\npoints in the target. The module allow supports enable/disabling thermal\r\nzones as well as change trip temperatures.\r\n\r\nSigned-off-by: Punit Agrawal <punit.agrawal@arm.com>","created_at":"2015-11-23T12:38:39Z","updated_at":"2015-11-24T09:45:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e8672c386a67380040ee3e60c4ea8a01ffa7707","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ARM-software/devlib/pulls/5/commits","review_comments_url":"https://api.github.com/repos/ARM-software/devlib/pulls/5/comments","review_comment_url":"https://api.github.com/repos/ARM-software/devlib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ARM-software/devlib/issues/5/comments","statuses_url":"https://api.github.com/repos/ARM-software/devlib/statuses/bce6ebbd5c8053f1fb255ba63ee82b009dfca3cf","head":{"label":"punitagrawal:master","ref":"master","sha":"bce6ebbd5c8053f1fb255ba63ee82b009dfca3cf","user":{"login":"punitagrawal","id":790730,"avatar_url":"https://avatars.githubusercontent.com/u/790730?v=3","gravatar_id":"","url":"https://api.github.com/users/punitagrawal","html_url":"https://github.com/punitagrawal","followers_url":"https://api.github.com/users/punitagrawal/followers","following_url":"https://api.github.com/users/punitagrawal/following{/other_user}","gists_url":"https://api.github.com/users/punitagrawal/gists{/gist_id}","starred_url":"https://api.github.com/users/punitagrawal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/punitagrawal/subscriptions","organizations_url":"https://api.github.com/users/punitagrawal/orgs","repos_url":"https://api.github.com/users/punitagrawal/repos","events_url":"https://api.github.com/users/punitagrawal/events{/privacy}","received_events_url":"https://api.github.com/users/punitagrawal/received_events","type":"User","site_admin":false},"repo":{"id":46719164,"name":"devlib","full_name":"punitagrawal/devlib","owner":{"login":"punitagrawal","id":790730,"avatar_url":"https://avatars.githubusercontent.com/u/790730?v=3","gravatar_id":"","url":"https://api.github.com/users/punitagrawal","html_url":"https://github.com/punitagrawal","followers_url":"https://api.github.com/users/punitagrawal/followers","following_url":"https://api.github.com/users/punitagrawal/following{/other_user}","gists_url":"https://api.github.com/users/punitagrawal/gists{/gist_id}","starred_url":"https://api.github.com/users/punitagrawal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/punitagrawal/subscriptions","organizations_url":"https://api.github.com/users/punitagrawal/orgs","repos_url":"https://api.github.com/users/punitagrawal/repos","events_url":"https://api.github.com/users/punitagrawal/events{/privacy}","received_events_url":"https://api.github.com/users/punitagrawal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/punitagrawal/devlib","description":"Library for interaction with and instrumentation of remote devices.","fork":true,"url":"https://api.github.com/repos/punitagrawal/devlib","forks_url":"https://api.github.com/repos/punitagrawal/devlib/forks","keys_url":"https://api.github.com/repos/punitagrawal/devlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/punitagrawal/devlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/punitagrawal/devlib/teams","hooks_url":"https://api.github.com/repos/punitagrawal/devlib/hooks","issue_events_url":"https://api.github.com/repos/punitagrawal/devlib/issues/events{/number}","events_url":"https://api.github.com/repos/punitagrawal/devlib/events","assignees_url":"https://api.github.com/repos/punitagrawal/devlib/assignees{/user}","branches_url":"https://api.github.com/repos/punitagrawal/devlib/branches{/branch}","tags_url":"https://api.github.com/repos/punitagrawal/devlib/tags","blobs_url":"https://api.github.com/repos/punitagrawal/devlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/punitagrawal/devlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/punitagrawal/devlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/punitagrawal/devlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/punitagrawal/devlib/statuses/{sha}","languages_url":"https://api.github.com/repos/punitagrawal/devlib/languages","stargazers_url":"https://api.github.com/repos/punitagrawal/devlib/stargazers","contributors_url":"https://api.github.com/repos/punitagrawal/devlib/contributors","subscribers_url":"https://api.github.com/repos/punitagrawal/devlib/subscribers","subscription_url":"https://api.github.com/repos/punitagrawal/devlib/subscription","commits_url":"https://api.github.com/repos/punitagrawal/devlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/punitagrawal/devlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/punitagrawal/devlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/punitagrawal/devlib/issues/comments{/number}","contents_url":"https://api.github.com/repos/punitagrawal/devlib/contents/{+path}","compare_url":"https://api.github.com/repos/punitagrawal/devlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/punitagrawal/devlib/merges","archive_url":"https://api.github.com/repos/punitagrawal/devlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/punitagrawal/devlib/downloads","issues_url":"https://api.github.com/repos/punitagrawal/devlib/issues{/number}","pulls_url":"https://api.github.com/repos/punitagrawal/devlib/pulls{/number}","milestones_url":"https://api.github.com/repos/punitagrawal/devlib/milestones{/number}","notifications_url":"https://api.github.com/repos/punitagrawal/devlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/punitagrawal/devlib/labels{/name}","releases_url":"https://api.github.com/repos/punitagrawal/devlib/releases{/id}","created_at":"2015-11-23T12:36:01Z","updated_at":"2015-11-23T12:36:02Z","pushed_at":"2015-11-23T12:37:07Z","git_url":"git://github.com/punitagrawal/devlib.git","ssh_url":"git@github.com:punitagrawal/devlib.git","clone_url":"https://github.com/punitagrawal/devlib.git","svn_url":"https://github.com/punitagrawal/devlib","homepage":null,"size":3502,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"ARM-software:master","ref":"master","sha":"40274101ad938485793cb2f115e18ff751479eec","user":{"login":"ARM-software","id":5690313,"avatar_url":"https://avatars.githubusercontent.com/u/5690313?v=3","gravatar_id":"","url":"https://api.github.com/users/ARM-software","html_url":"https://github.com/ARM-software","followers_url":"https://api.github.com/users/ARM-software/followers","following_url":"https://api.github.com/users/ARM-software/following{/other_user}","gists_url":"https://api.github.com/users/ARM-software/gists{/gist_id}","starred_url":"https://api.github.com/users/ARM-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARM-software/subscriptions","organizations_url":"https://api.github.com/users/ARM-software/orgs","repos_url":"https://api.github.com/users/ARM-software/repos","events_url":"https://api.github.com/users/ARM-software/events{/privacy}","received_events_url":"https://api.github.com/users/ARM-software/received_events","type":"Organization","site_admin":false},"repo":{"id":43942363,"name":"devlib","full_name":"ARM-software/devlib","owner":{"login":"ARM-software","id":5690313,"avatar_url":"https://avatars.githubusercontent.com/u/5690313?v=3","gravatar_id":"","url":"https://api.github.com/users/ARM-software","html_url":"https://github.com/ARM-software","followers_url":"https://api.github.com/users/ARM-software/followers","following_url":"https://api.github.com/users/ARM-software/following{/other_user}","gists_url":"https://api.github.com/users/ARM-software/gists{/gist_id}","starred_url":"https://api.github.com/users/ARM-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARM-software/subscriptions","organizations_url":"https://api.github.com/users/ARM-software/orgs","repos_url":"https://api.github.com/users/ARM-software/repos","events_url":"https://api.github.com/users/ARM-software/events{/privacy}","received_events_url":"https://api.github.com/users/ARM-software/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ARM-software/devlib","description":"Library for interaction with and instrumentation of remote devices.","fork":false,"url":"https://api.github.com/repos/ARM-software/devlib","forks_url":"https://api.github.com/repos/ARM-software/devlib/forks","keys_url":"https://api.github.com/repos/ARM-software/devlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ARM-software/devlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ARM-software/devlib/teams","hooks_url":"https://api.github.com/repos/ARM-software/devlib/hooks","issue_events_url":"https://api.github.com/repos/ARM-software/devlib/issues/events{/number}","events_url":"https://api.github.com/repos/ARM-software/devlib/events","assignees_url":"https://api.github.com/repos/ARM-software/devlib/assignees{/user}","branches_url":"https://api.github.com/repos/ARM-software/devlib/branches{/branch}","tags_url":"https://api.github.com/repos/ARM-software/devlib/tags","blobs_url":"https://api.github.com/repos/ARM-software/devlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ARM-software/devlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ARM-software/devlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/ARM-software/devlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ARM-software/devlib/statuses/{sha}","languages_url":"https://api.github.com/repos/ARM-software/devlib/languages","stargazers_url":"https://api.github.com/repos/ARM-software/devlib/stargazers","contributors_url":"https://api.github.com/repos/ARM-software/devlib/contributors","subscribers_url":"https://api.github.com/repos/ARM-software/devlib/subscribers","subscription_url":"https://api.github.com/repos/ARM-software/devlib/subscription","commits_url":"https://api.github.com/repos/ARM-software/devlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/ARM-software/devlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/ARM-software/devlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/ARM-software/devlib/issues/comments{/number}","contents_url":"https://api.github.com/repos/ARM-software/devlib/contents/{+path}","compare_url":"https://api.github.com/repos/ARM-software/devlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ARM-software/devlib/merges","archive_url":"https://api.github.com/repos/ARM-software/devlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ARM-software/devlib/downloads","issues_url":"https://api.github.com/repos/ARM-software/devlib/issues{/number}","pulls_url":"https://api.github.com/repos/ARM-software/devlib/pulls{/number}","milestones_url":"https://api.github.com/repos/ARM-software/devlib/milestones{/number}","notifications_url":"https://api.github.com/repos/ARM-software/devlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ARM-software/devlib/labels{/name}","releases_url":"https://api.github.com/repos/ARM-software/devlib/releases{/id}","created_at":"2015-10-09T08:22:12Z","updated_at":"2015-11-11T18:10:39Z","pushed_at":"2015-11-23T12:38:39Z","git_url":"git://github.com/ARM-software/devlib.git","ssh_url":"git@github.com:ARM-software/devlib.git","clone_url":"https://github.com/ARM-software/devlib.git","svn_url":"https://github.com/ARM-software/devlib","homepage":null,"size":3501,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ARM-software/devlib/pulls/5"},"html":{"href":"https://github.com/ARM-software/devlib/pull/5"},"issue":{"href":"https://api.github.com/repos/ARM-software/devlib/issues/5"},"comments":{"href":"https://api.github.com/repos/ARM-software/devlib/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/ARM-software/devlib/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/ARM-software/devlib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ARM-software/devlib/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/ARM-software/devlib/statuses/bce6ebbd5c8053f1fb255ba63ee82b009dfca3cf"}}}}