{"action":"created","comment":{"url":"https://api.github.com/repos/project-rig/rig/pulls/comments/26562302","id":26562302,"diff_hunk":"@@ -0,0 +1,114 @@\n+\"\"\"A minimal command-line utility for booting SpiNNaker machines.\n+\n+Installed as \"rig-boot\" by setuptools.\n+\"\"\"\n+\n+import sys\n+import argparse\n+\n+from rig.machine_control import boot, MachineController\n+\n+from rig.machine_control.scp_connection import TimeoutError\n+\n+BOOT_OPTION_POSTFIX = \"_boot_options\"\n+\"\"\"Postfix for boot option dicts in boot.\"\"\"\n+\n+\n+def main(args=None):\n+    parser = argparse.ArgumentParser(description=\"Boot a SpiNNaker board\")\n+    parser.add_argument(\"hostname\", type=str,\n+                        help=\"hostname or IP of SpiNNaker system\")\n+\n+    parser.add_argument(\"width\", type=int, default=None, nargs=\"?\",\n+                        help=\"width of SpiNNaker system\")\n+    parser.add_argument(\"height\", type=int, default=None, nargs=\"?\",\n+                        help=\"height of SpiNNaker system\")\n+    parser.add_argument(\"--hardware-version\", type=int, default=None,\n+                        help=\"board hardware version number\")\n+    parser.add_argument(\"--led-config\", type=int, default=None,\n+                        help=\"LED configuration word\")\n+\n+    parser.add_argument(\"--binary\", type=str, default=None,\n+                        help=\"binary to boot the system with\")\n+\n+    # Automatically build a list of available machine parameters by inspecting\n+    # boot module.\n+    type_group = parser.add_mutually_exclusive_group()\n+    for dict_name in dir(boot):\n+        if dict_name.endswith(BOOT_OPTION_POSTFIX):\n+            type_name = dict_name[:-len(BOOT_OPTION_POSTFIX)]\n+            option_name = \"--{}\".format(type_name)\n+            option_dict = getattr(boot, dict_name)\n+            option_help = \"use predefined boot options for a {} board\".format(\n+                type_name)\n+            type_group.add_argument(option_name, action=\"store_const\",\n+                                    const=option_dict, default={},\n+                                    dest=\"machine_type\",\n+                                    help=option_help)\n+\n+    args = parser.parse_args(args)\n+\n+    # Check that either a width and height have been supplied or a predefined\n+    # set of machine parameters was chosen.\n+    if (args.width is None and args.height is None and\n+            args.machine_type == {}):\n+        parser.error(\"either width and height must be specified \"\n+                     \"or a predefined boot option selected.\")\n+    elif (args.width is None) ^ (args.height is None):\n+        parser.error(\"if used, both width and height must be specified\")\n+\n+    # Accumulate the set of options from the commandline\n+    options = {\n+        \"hardware_version\": 0,\n+        \"led_config\": 0x00000001,\n+        \"boot_data\": (open(args.binary, \"rb\").read()\n+                      if args.binary is not None else None),\n+    }\n+    options.update(args.machine_type)\n+    options.update({\n+        opt_name: getattr(args, opt_name)\n+        for opt_name in \"width height hardware_version led_config\".split()\n+        if getattr(args, opt_name) is not None\n+    })\n+\n+    # See if the device is already booted\n+    mc = MachineController(args.hostname, n_tries=1)\n+    try:\n+        info = mc.get_software_version(0, 0)\n+        if \"SpiNNaker\" in info.version_string:\n+            sys.stderr.write(\n+                \"{}: error: system already booted with {} v{}\\n\".format(\n+                    parser.prog,\n+                    info.version_string.split(\"/\")[0],\n+                    info.version))\n+            return 1\n+        else:\n+            sys.stderr.write(\n+                \"{}: error: host is not a SpiNNaker system \"\n+                \"({} running {} v{})\\n\".format(","path":"rig/scripts/rig_boot.py","position":88,"original_position":88,"commit_id":"084efc75e99f5ccb144f3e97518244778e3961aa","original_commit_id":"f25e6bcf5c73826971a19f1d665d713715b637e6","user":{"login":"mundya","id":3439837,"avatar_url":"https://avatars.githubusercontent.com/u/3439837?v=3","gravatar_id":"","url":"https://api.github.com/users/mundya","html_url":"https://github.com/mundya","followers_url":"https://api.github.com/users/mundya/followers","following_url":"https://api.github.com/users/mundya/following{/other_user}","gists_url":"https://api.github.com/users/mundya/gists{/gist_id}","starred_url":"https://api.github.com/users/mundya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mundya/subscriptions","organizations_url":"https://api.github.com/users/mundya/orgs","repos_url":"https://api.github.com/users/mundya/repos","events_url":"https://api.github.com/users/mundya/events{/privacy}","received_events_url":"https://api.github.com/users/mundya/received_events","type":"User","site_admin":false},"body":"I can imagine!","created_at":"2015-03-17T10:35:09Z","updated_at":"2015-03-17T10:35:09Z","html_url":"https://github.com/project-rig/rig/pull/66#discussion_r26562302","pull_request_url":"https://api.github.com/repos/project-rig/rig/pulls/66","_links":{"self":{"href":"https://api.github.com/repos/project-rig/rig/pulls/comments/26562302"},"html":{"href":"https://github.com/project-rig/rig/pull/66#discussion_r26562302"},"pull_request":{"href":"https://api.github.com/repos/project-rig/rig/pulls/66"}}},"pull_request":{"url":"https://api.github.com/repos/project-rig/rig/pulls/66","id":31257240,"html_url":"https://github.com/project-rig/rig/pull/66","diff_url":"https://github.com/project-rig/rig/pull/66.diff","patch_url":"https://github.com/project-rig/rig/pull/66.patch","issue_url":"https://api.github.com/repos/project-rig/rig/issues/66","number":66,"state":"open","locked":false,"title":"Add a few simple rig commandline tools","user":{"login":"mossblaser","id":193514,"avatar_url":"https://avatars.githubusercontent.com/u/193514?v=3","gravatar_id":"","url":"https://api.github.com/users/mossblaser","html_url":"https://github.com/mossblaser","followers_url":"https://api.github.com/users/mossblaser/followers","following_url":"https://api.github.com/users/mossblaser/following{/other_user}","gists_url":"https://api.github.com/users/mossblaser/gists{/gist_id}","starred_url":"https://api.github.com/users/mossblaser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mossblaser/subscriptions","organizations_url":"https://api.github.com/users/mossblaser/orgs","repos_url":"https://api.github.com/users/mossblaser/repos","events_url":"https://api.github.com/users/mossblaser/events{/privacy}","received_events_url":"https://api.github.com/users/mossblaser/received_events","type":"User","site_admin":false},"body":"Add a selection of simple single-purpose tools which are useful when working with rig:\r\n\r\n* [x] `rig-boot` -- boot a SpiNNaker system\r\n* [x] `rig-power` -- power on/off a SpiNNaker machine (via the BMP)\r\n* [x] `rig-info` -- Given a SpiNNaker board or BMP, report basic info:\r\n  * [x] Software version\r\n  * [x] Working Chips/Cores/Links (SpiNNaker only)\r\n  * [x] Temperature/Fan-speed (BMP only)","created_at":"2015-03-16T16:04:22Z","updated_at":"2015-03-17T10:35:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3500635af77a43f502f6c32021e1ab6f3b6b55f7","assignee":{"login":"mundya","id":3439837,"avatar_url":"https://avatars.githubusercontent.com/u/3439837?v=3","gravatar_id":"","url":"https://api.github.com/users/mundya","html_url":"https://github.com/mundya","followers_url":"https://api.github.com/users/mundya/followers","following_url":"https://api.github.com/users/mundya/following{/other_user}","gists_url":"https://api.github.com/users/mundya/gists{/gist_id}","starred_url":"https://api.github.com/users/mundya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mundya/subscriptions","organizations_url":"https://api.github.com/users/mundya/orgs","repos_url":"https://api.github.com/users/mundya/repos","events_url":"https://api.github.com/users/mundya/events{/privacy}","received_events_url":"https://api.github.com/users/mundya/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/project-rig/rig/pulls/66/commits","review_comments_url":"https://api.github.com/repos/project-rig/rig/pulls/66/comments","review_comment_url":"https://api.github.com/repos/project-rig/rig/pulls/comments{/number}","comments_url":"https://api.github.com/repos/project-rig/rig/issues/66/comments","statuses_url":"https://api.github.com/repos/project-rig/rig/statuses/084efc75e99f5ccb144f3e97518244778e3961aa","head":{"label":"project-rig:rig-commands","ref":"rig-commands","sha":"084efc75e99f5ccb144f3e97518244778e3961aa","user":{"login":"project-rig","id":11227885,"avatar_url":"https://avatars.githubusercontent.com/u/11227885?v=3","gravatar_id":"","url":"https://api.github.com/users/project-rig","html_url":"https://github.com/project-rig","followers_url":"https://api.github.com/users/project-rig/followers","following_url":"https://api.github.com/users/project-rig/following{/other_user}","gists_url":"https://api.github.com/users/project-rig/gists{/gist_id}","starred_url":"https://api.github.com/users/project-rig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-rig/subscriptions","organizations_url":"https://api.github.com/users/project-rig/orgs","repos_url":"https://api.github.com/users/project-rig/repos","events_url":"https://api.github.com/users/project-rig/events{/privacy}","received_events_url":"https://api.github.com/users/project-rig/received_events","type":"Organization","site_admin":false},"repo":{"id":29497314,"name":"rig","full_name":"project-rig/rig","owner":{"login":"project-rig","id":11227885,"avatar_url":"https://avatars.githubusercontent.com/u/11227885?v=3","gravatar_id":"","url":"https://api.github.com/users/project-rig","html_url":"https://github.com/project-rig","followers_url":"https://api.github.com/users/project-rig/followers","following_url":"https://api.github.com/users/project-rig/following{/other_user}","gists_url":"https://api.github.com/users/project-rig/gists{/gist_id}","starred_url":"https://api.github.com/users/project-rig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-rig/subscriptions","organizations_url":"https://api.github.com/users/project-rig/orgs","repos_url":"https://api.github.com/users/project-rig/repos","events_url":"https://api.github.com/users/project-rig/events{/privacy}","received_events_url":"https://api.github.com/users/project-rig/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/project-rig/rig","description":"A set of tools for rigging SpiNNaker programs.","fork":false,"url":"https://api.github.com/repos/project-rig/rig","forks_url":"https://api.github.com/repos/project-rig/rig/forks","keys_url":"https://api.github.com/repos/project-rig/rig/keys{/key_id}","collaborators_url":"https://api.github.com/repos/project-rig/rig/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/project-rig/rig/teams","hooks_url":"https://api.github.com/repos/project-rig/rig/hooks","issue_events_url":"https://api.github.com/repos/project-rig/rig/issues/events{/number}","events_url":"https://api.github.com/repos/project-rig/rig/events","assignees_url":"https://api.github.com/repos/project-rig/rig/assignees{/user}","branches_url":"https://api.github.com/repos/project-rig/rig/branches{/branch}","tags_url":"https://api.github.com/repos/project-rig/rig/tags","blobs_url":"https://api.github.com/repos/project-rig/rig/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/project-rig/rig/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/project-rig/rig/git/refs{/sha}","trees_url":"https://api.github.com/repos/project-rig/rig/git/trees{/sha}","statuses_url":"https://api.github.com/repos/project-rig/rig/statuses/{sha}","languages_url":"https://api.github.com/repos/project-rig/rig/languages","stargazers_url":"https://api.github.com/repos/project-rig/rig/stargazers","contributors_url":"https://api.github.com/repos/project-rig/rig/contributors","subscribers_url":"https://api.github.com/repos/project-rig/rig/subscribers","subscription_url":"https://api.github.com/repos/project-rig/rig/subscription","commits_url":"https://api.github.com/repos/project-rig/rig/commits{/sha}","git_commits_url":"https://api.github.com/repos/project-rig/rig/git/commits{/sha}","comments_url":"https://api.github.com/repos/project-rig/rig/comments{/number}","issue_comment_url":"https://api.github.com/repos/project-rig/rig/issues/comments{/number}","contents_url":"https://api.github.com/repos/project-rig/rig/contents/{+path}","compare_url":"https://api.github.com/repos/project-rig/rig/compare/{base}...{head}","merges_url":"https://api.github.com/repos/project-rig/rig/merges","archive_url":"https://api.github.com/repos/project-rig/rig/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/project-rig/rig/downloads","issues_url":"https://api.github.com/repos/project-rig/rig/issues{/number}","pulls_url":"https://api.github.com/repos/project-rig/rig/pulls{/number}","milestones_url":"https://api.github.com/repos/project-rig/rig/milestones{/number}","notifications_url":"https://api.github.com/repos/project-rig/rig/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/project-rig/rig/labels{/name}","releases_url":"https://api.github.com/repos/project-rig/rig/releases{/id}","created_at":"2015-01-19T21:20:40Z","updated_at":"2015-03-17T07:33:44Z","pushed_at":"2015-03-17T10:32:25Z","git_url":"git://github.com/project-rig/rig.git","ssh_url":"git@github.com:project-rig/rig.git","clone_url":"https://github.com/project-rig/rig.git","svn_url":"https://github.com/project-rig/rig","homepage":"","size":1911,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":0,"default_branch":"master"}},"base":{"label":"project-rig:master","ref":"master","sha":"6c73586f1cc528a1c5a070e2d910c3bb14064861","user":{"login":"project-rig","id":11227885,"avatar_url":"https://avatars.githubusercontent.com/u/11227885?v=3","gravatar_id":"","url":"https://api.github.com/users/project-rig","html_url":"https://github.com/project-rig","followers_url":"https://api.github.com/users/project-rig/followers","following_url":"https://api.github.com/users/project-rig/following{/other_user}","gists_url":"https://api.github.com/users/project-rig/gists{/gist_id}","starred_url":"https://api.github.com/users/project-rig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-rig/subscriptions","organizations_url":"https://api.github.com/users/project-rig/orgs","repos_url":"https://api.github.com/users/project-rig/repos","events_url":"https://api.github.com/users/project-rig/events{/privacy}","received_events_url":"https://api.github.com/users/project-rig/received_events","type":"Organization","site_admin":false},"repo":{"id":29497314,"name":"rig","full_name":"project-rig/rig","owner":{"login":"project-rig","id":11227885,"avatar_url":"https://avatars.githubusercontent.com/u/11227885?v=3","gravatar_id":"","url":"https://api.github.com/users/project-rig","html_url":"https://github.com/project-rig","followers_url":"https://api.github.com/users/project-rig/followers","following_url":"https://api.github.com/users/project-rig/following{/other_user}","gists_url":"https://api.github.com/users/project-rig/gists{/gist_id}","starred_url":"https://api.github.com/users/project-rig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-rig/subscriptions","organizations_url":"https://api.github.com/users/project-rig/orgs","repos_url":"https://api.github.com/users/project-rig/repos","events_url":"https://api.github.com/users/project-rig/events{/privacy}","received_events_url":"https://api.github.com/users/project-rig/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/project-rig/rig","description":"A set of tools for rigging SpiNNaker programs.","fork":false,"url":"https://api.github.com/repos/project-rig/rig","forks_url":"https://api.github.com/repos/project-rig/rig/forks","keys_url":"https://api.github.com/repos/project-rig/rig/keys{/key_id}","collaborators_url":"https://api.github.com/repos/project-rig/rig/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/project-rig/rig/teams","hooks_url":"https://api.github.com/repos/project-rig/rig/hooks","issue_events_url":"https://api.github.com/repos/project-rig/rig/issues/events{/number}","events_url":"https://api.github.com/repos/project-rig/rig/events","assignees_url":"https://api.github.com/repos/project-rig/rig/assignees{/user}","branches_url":"https://api.github.com/repos/project-rig/rig/branches{/branch}","tags_url":"https://api.github.com/repos/project-rig/rig/tags","blobs_url":"https://api.github.com/repos/project-rig/rig/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/project-rig/rig/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/project-rig/rig/git/refs{/sha}","trees_url":"https://api.github.com/repos/project-rig/rig/git/trees{/sha}","statuses_url":"https://api.github.com/repos/project-rig/rig/statuses/{sha}","languages_url":"https://api.github.com/repos/project-rig/rig/languages","stargazers_url":"https://api.github.com/repos/project-rig/rig/stargazers","contributors_url":"https://api.github.com/repos/project-rig/rig/contributors","subscribers_url":"https://api.github.com/repos/project-rig/rig/subscribers","subscription_url":"https://api.github.com/repos/project-rig/rig/subscription","commits_url":"https://api.github.com/repos/project-rig/rig/commits{/sha}","git_commits_url":"https://api.github.com/repos/project-rig/rig/git/commits{/sha}","comments_url":"https://api.github.com/repos/project-rig/rig/comments{/number}","issue_comment_url":"https://api.github.com/repos/project-rig/rig/issues/comments{/number}","contents_url":"https://api.github.com/repos/project-rig/rig/contents/{+path}","compare_url":"https://api.github.com/repos/project-rig/rig/compare/{base}...{head}","merges_url":"https://api.github.com/repos/project-rig/rig/merges","archive_url":"https://api.github.com/repos/project-rig/rig/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/project-rig/rig/downloads","issues_url":"https://api.github.com/repos/project-rig/rig/issues{/number}","pulls_url":"https://api.github.com/repos/project-rig/rig/pulls{/number}","milestones_url":"https://api.github.com/repos/project-rig/rig/milestones{/number}","notifications_url":"https://api.github.com/repos/project-rig/rig/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/project-rig/rig/labels{/name}","releases_url":"https://api.github.com/repos/project-rig/rig/releases{/id}","created_at":"2015-01-19T21:20:40Z","updated_at":"2015-03-17T07:33:44Z","pushed_at":"2015-03-17T10:32:25Z","git_url":"git://github.com/project-rig/rig.git","ssh_url":"git@github.com:project-rig/rig.git","clone_url":"https://github.com/project-rig/rig.git","svn_url":"https://github.com/project-rig/rig","homepage":"","size":1911,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/project-rig/rig/pulls/66"},"html":{"href":"https://github.com/project-rig/rig/pull/66"},"issue":{"href":"https://api.github.com/repos/project-rig/rig/issues/66"},"comments":{"href":"https://api.github.com/repos/project-rig/rig/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/project-rig/rig/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/project-rig/rig/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/project-rig/rig/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/project-rig/rig/statuses/084efc75e99f5ccb144f3e97518244778e3961aa"}}}}