{"action":"created","comment":{"url":"https://api.github.com/repos/ARMmbed/htrun/pulls/comments/119464886","pull_request_review_id":41346318,"id":119464886,"diff_hunk":"@@ -17,96 +17,91 @@\n Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>\n \"\"\"\n \n-import re\n-from os.path import join\n+import os\n+from shutil import copy\n from host_test_plugins import HostTestPluginBase\n \n \n class HostTestPluginCopyMethod_MPS2(HostTestPluginBase):\n-    # MPS2 specific flashing / binary setup funcitons\n+    \"\"\" Generic flashing method for mbed-enabled devices (by copy)\n+    \"\"\"\n+\n+\n+    name = 'HostTestPluginCopyMethod_MPS2'\n+    type = 'CopyMethod'\n+    stable = True\n+    capabilities = ['mps2']\n+    required_parameters = ['image_path', 'destination_disk']\n \n     def __init__(self):\n         \"\"\" ctor\n         \"\"\"\n         HostTestPluginBase.__init__(self)\n \n-    def mps2_set_board_image_file(self, disk, images_cfg_path, image0file_path, image_name='images.txt'):\n-        \"\"\" This function will alter image cfg file\n-\n-        @details Main goal of this function is to change number of images to 1, comment all\n-                 existing image entries and append at the end of file new entry with test path\n-\n-        @return True when all steps were successful\n-        \"\"\"\n-        MBED_SDK_TEST_STAMP = 'test suite entry'\n-        image_path = join(disk, images_cfg_path, image_name)\n-        new_file_lines = [] # New configuration file lines (entries)\n-\n-        # Check each line of the image configuration file\n-        try:\n-            with open(image_path, 'r') as file:\n-                for line in file:\n-                    if re.search('^TOTALIMAGES', line):\n-                        # Check number of total images, should be 1\n-                        new_file_lines.append(re.sub('^TOTALIMAGES:[\\t ]*[\\d]+', 'TOTALIMAGES: 1', line))\n-                    elif re.search('; - %s[\\n\\r]*$'% MBED_SDK_TEST_STAMP, line):\n-                        # Look for test suite entries and remove them\n-                        pass    # Omit all test suite entries\n-                    elif re.search('^IMAGE[\\d]+FILE', line):\n-                        # Check all image entries and mark the ';'\n-                        new_file_lines.append(';' + line)   # Comment non test suite lines\n-                    else:\n-                        # Append line to new file\n-                        new_file_lines.append(line)\n-        except IOError as e:\n-            return False\n-\n-        # Add new image entry with proper commented stamp\n-        new_file_lines.append('IMAGE0FILE: %s    ; - %s\\r\\n'% (image0file_path, MBED_SDK_TEST_STAMP))\n-\n-        # Write all lines to file\n-        try:\n-            with open(image_path, 'w') as file:\n-                for line in new_file_lines:\n-                    file.write(line),\n-        except IOError:\n-            return False\n+    def generic_mbed_copy(self, image_path, destination_disk):\n+        \"\"\"! Generic mbed copy method for \"mbed enabled\" devices.\n \n-        return True\n+        @param image_path Path to binary file to be flashed\n+        @param destination_disk Path to destination (mbed mount point)\n \n-    def mps2_select_core(self, disk, mobo_config_name=\"\"):\n-        \"\"\" Function selects actual core\n-        \"\"\"\n-        # TODO: implement core selection\n-        pass\n+        @details It uses standard python shutil function to copy image_file (target specific binary) to device's disk.\n \n-    def mps2_switch_usb_auto_mounting_after_restart(self, disk, usb_config_name=\"\"):\n-        \"\"\" Function alters configuration to allow USB MSD to be mounted after restarts\n+        @return Returns True if copy (flashing) was successful\n         \"\"\"\n-        # TODO: implement USB MSD restart detection\n-        pass\n+        result = True\n+        destination_path = os.path.join(destination_disk,\"mbed.bin\")\n+        try:\n+            copy(image_path, destination_path)","path":"mbed_host_tests/host_tests_plugins/module_copy_mps2.py","position":92,"original_position":92,"commit_id":"7a3c8fd8dfb13a03107b0914bc578f56d3bedbe5","original_commit_id":"7a3c8fd8dfb13a03107b0914bc578f56d3bedbe5","user":{"login":"bridadan","id":3123977,"avatar_url":"https://avatars1.githubusercontent.com/u/3123977?v=3","gravatar_id":"","url":"https://api.github.com/users/bridadan","html_url":"https://github.com/bridadan","followers_url":"https://api.github.com/users/bridadan/followers","following_url":"https://api.github.com/users/bridadan/following{/other_user}","gists_url":"https://api.github.com/users/bridadan/gists{/gist_id}","starred_url":"https://api.github.com/users/bridadan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bridadan/subscriptions","organizations_url":"https://api.github.com/users/bridadan/orgs","repos_url":"https://api.github.com/users/bridadan/repos","events_url":"https://api.github.com/users/bridadan/events{/privacy}","received_events_url":"https://api.github.com/users/bridadan/received_events","type":"User","site_admin":false},"body":"I know we tested with this copy method, however this uses `shutil` to do the copying. On Linux, this isn't a \"blocking\" write if I remember correctly. Ideally it should be.\r\n\r\nThe default method uses `cp` followed by `sync`. We should most likely be using the same method here as well before this gets merged to master. (For reference, here's the default copy method: https://github.com/ARMmbed/htrun/blob/master/mbed_host_tests/host_tests_plugins/module_copy_shell.py#L76)","created_at":"2017-05-31T20:28:38Z","updated_at":"2017-05-31T20:31:41Z","html_url":"https://github.com/ARMmbed/htrun/pull/160#discussion_r119464886","pull_request_url":"https://api.github.com/repos/ARMmbed/htrun/pulls/160","_links":{"self":{"href":"https://api.github.com/repos/ARMmbed/htrun/pulls/comments/119464886"},"html":{"href":"https://github.com/ARMmbed/htrun/pull/160#discussion_r119464886"},"pull_request":{"href":"https://api.github.com/repos/ARMmbed/htrun/pulls/160"}}},"pull_request":{"url":"https://api.github.com/repos/ARMmbed/htrun/pulls/160","id":123346971,"html_url":"https://github.com/ARMmbed/htrun/pull/160","diff_url":"https://github.com/ARMmbed/htrun/pull/160.diff","patch_url":"https://github.com/ARMmbed/htrun/pull/160.patch","issue_url":"https://api.github.com/repos/ARMmbed/htrun/issues/160","number":160,"state":"open","locked":false,"title":"Support reset and flash for ARM MPS2 board.","user":{"login":"studavekar","id":25986241,"avatar_url":"https://avatars0.githubusercontent.com/u/25986241?v=3","gravatar_id":"","url":"https://api.github.com/users/studavekar","html_url":"https://github.com/studavekar","followers_url":"https://api.github.com/users/studavekar/followers","following_url":"https://api.github.com/users/studavekar/following{/other_user}","gists_url":"https://api.github.com/users/studavekar/gists{/gist_id}","starred_url":"https://api.github.com/users/studavekar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/studavekar/subscriptions","organizations_url":"https://api.github.com/users/studavekar/orgs","repos_url":"https://api.github.com/users/studavekar/repos","events_url":"https://api.github.com/users/studavekar/events{/privacy}","received_events_url":"https://api.github.com/users/studavekar/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-05-31T19:13:23Z","updated_at":"2017-05-31T20:31:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"210e573ff33ffd2e0677649f7a01c0bea0ffd1fa","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/ARMmbed/htrun/pulls/160/commits","review_comments_url":"https://api.github.com/repos/ARMmbed/htrun/pulls/160/comments","review_comment_url":"https://api.github.com/repos/ARMmbed/htrun/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ARMmbed/htrun/issues/160/comments","statuses_url":"https://api.github.com/repos/ARMmbed/htrun/statuses/7a3c8fd8dfb13a03107b0914bc578f56d3bedbe5","head":{"label":"studavekar:arm-mps2-support-re","ref":"arm-mps2-support-re","sha":"7a3c8fd8dfb13a03107b0914bc578f56d3bedbe5","user":{"login":"studavekar","id":25986241,"avatar_url":"https://avatars0.githubusercontent.com/u/25986241?v=3","gravatar_id":"","url":"https://api.github.com/users/studavekar","html_url":"https://github.com/studavekar","followers_url":"https://api.github.com/users/studavekar/followers","following_url":"https://api.github.com/users/studavekar/following{/other_user}","gists_url":"https://api.github.com/users/studavekar/gists{/gist_id}","starred_url":"https://api.github.com/users/studavekar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/studavekar/subscriptions","organizations_url":"https://api.github.com/users/studavekar/orgs","repos_url":"https://api.github.com/users/studavekar/repos","events_url":"https://api.github.com/users/studavekar/events{/privacy}","received_events_url":"https://api.github.com/users/studavekar/received_events","type":"User","site_admin":false},"repo":{"id":91034405,"name":"htrun","full_name":"studavekar/htrun","owner":{"login":"studavekar","id":25986241,"avatar_url":"https://avatars0.githubusercontent.com/u/25986241?v=3","gravatar_id":"","url":"https://api.github.com/users/studavekar","html_url":"https://github.com/studavekar","followers_url":"https://api.github.com/users/studavekar/followers","following_url":"https://api.github.com/users/studavekar/following{/other_user}","gists_url":"https://api.github.com/users/studavekar/gists{/gist_id}","starred_url":"https://api.github.com/users/studavekar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/studavekar/subscriptions","organizations_url":"https://api.github.com/users/studavekar/orgs","repos_url":"https://api.github.com/users/studavekar/repos","events_url":"https://api.github.com/users/studavekar/events{/privacy}","received_events_url":"https://api.github.com/users/studavekar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/studavekar/htrun","description":"Flash, reset and  perform host supervised tests on mbed platforms.","fork":true,"url":"https://api.github.com/repos/studavekar/htrun","forks_url":"https://api.github.com/repos/studavekar/htrun/forks","keys_url":"https://api.github.com/repos/studavekar/htrun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/studavekar/htrun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/studavekar/htrun/teams","hooks_url":"https://api.github.com/repos/studavekar/htrun/hooks","issue_events_url":"https://api.github.com/repos/studavekar/htrun/issues/events{/number}","events_url":"https://api.github.com/repos/studavekar/htrun/events","assignees_url":"https://api.github.com/repos/studavekar/htrun/assignees{/user}","branches_url":"https://api.github.com/repos/studavekar/htrun/branches{/branch}","tags_url":"https://api.github.com/repos/studavekar/htrun/tags","blobs_url":"https://api.github.com/repos/studavekar/htrun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/studavekar/htrun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/studavekar/htrun/git/refs{/sha}","trees_url":"https://api.github.com/repos/studavekar/htrun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/studavekar/htrun/statuses/{sha}","languages_url":"https://api.github.com/repos/studavekar/htrun/languages","stargazers_url":"https://api.github.com/repos/studavekar/htrun/stargazers","contributors_url":"https://api.github.com/repos/studavekar/htrun/contributors","subscribers_url":"https://api.github.com/repos/studavekar/htrun/subscribers","subscription_url":"https://api.github.com/repos/studavekar/htrun/subscription","commits_url":"https://api.github.com/repos/studavekar/htrun/commits{/sha}","git_commits_url":"https://api.github.com/repos/studavekar/htrun/git/commits{/sha}","comments_url":"https://api.github.com/repos/studavekar/htrun/comments{/number}","issue_comment_url":"https://api.github.com/repos/studavekar/htrun/issues/comments{/number}","contents_url":"https://api.github.com/repos/studavekar/htrun/contents/{+path}","compare_url":"https://api.github.com/repos/studavekar/htrun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/studavekar/htrun/merges","archive_url":"https://api.github.com/repos/studavekar/htrun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/studavekar/htrun/downloads","issues_url":"https://api.github.com/repos/studavekar/htrun/issues{/number}","pulls_url":"https://api.github.com/repos/studavekar/htrun/pulls{/number}","milestones_url":"https://api.github.com/repos/studavekar/htrun/milestones{/number}","notifications_url":"https://api.github.com/repos/studavekar/htrun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/studavekar/htrun/labels{/name}","releases_url":"https://api.github.com/repos/studavekar/htrun/releases{/id}","deployments_url":"https://api.github.com/repos/studavekar/htrun/deployments","created_at":"2017-05-12T00:22:32Z","updated_at":"2017-05-12T00:22:34Z","pushed_at":"2017-05-31T19:03:15Z","git_url":"git://github.com/studavekar/htrun.git","ssh_url":"git@github.com:studavekar/htrun.git","clone_url":"https://github.com/studavekar/htrun.git","svn_url":"https://github.com/studavekar/htrun","homepage":"","size":638,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"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":"ARMmbed:master","ref":"master","sha":"edf385311223c31627a1aa511e7a57046599f0b3","user":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars0.githubusercontent.com/u/8916057?v=3","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"repo":{"id":30917094,"name":"htrun","full_name":"ARMmbed/htrun","owner":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars0.githubusercontent.com/u/8916057?v=3","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ARMmbed/htrun","description":"Flash, reset and  perform host supervised tests on mbed platforms.","fork":false,"url":"https://api.github.com/repos/ARMmbed/htrun","forks_url":"https://api.github.com/repos/ARMmbed/htrun/forks","keys_url":"https://api.github.com/repos/ARMmbed/htrun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ARMmbed/htrun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ARMmbed/htrun/teams","hooks_url":"https://api.github.com/repos/ARMmbed/htrun/hooks","issue_events_url":"https://api.github.com/repos/ARMmbed/htrun/issues/events{/number}","events_url":"https://api.github.com/repos/ARMmbed/htrun/events","assignees_url":"https://api.github.com/repos/ARMmbed/htrun/assignees{/user}","branches_url":"https://api.github.com/repos/ARMmbed/htrun/branches{/branch}","tags_url":"https://api.github.com/repos/ARMmbed/htrun/tags","blobs_url":"https://api.github.com/repos/ARMmbed/htrun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ARMmbed/htrun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ARMmbed/htrun/git/refs{/sha}","trees_url":"https://api.github.com/repos/ARMmbed/htrun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ARMmbed/htrun/statuses/{sha}","languages_url":"https://api.github.com/repos/ARMmbed/htrun/languages","stargazers_url":"https://api.github.com/repos/ARMmbed/htrun/stargazers","contributors_url":"https://api.github.com/repos/ARMmbed/htrun/contributors","subscribers_url":"https://api.github.com/repos/ARMmbed/htrun/subscribers","subscription_url":"https://api.github.com/repos/ARMmbed/htrun/subscription","commits_url":"https://api.github.com/repos/ARMmbed/htrun/commits{/sha}","git_commits_url":"https://api.github.com/repos/ARMmbed/htrun/git/commits{/sha}","comments_url":"https://api.github.com/repos/ARMmbed/htrun/comments{/number}","issue_comment_url":"https://api.github.com/repos/ARMmbed/htrun/issues/comments{/number}","contents_url":"https://api.github.com/repos/ARMmbed/htrun/contents/{+path}","compare_url":"https://api.github.com/repos/ARMmbed/htrun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ARMmbed/htrun/merges","archive_url":"https://api.github.com/repos/ARMmbed/htrun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ARMmbed/htrun/downloads","issues_url":"https://api.github.com/repos/ARMmbed/htrun/issues{/number}","pulls_url":"https://api.github.com/repos/ARMmbed/htrun/pulls{/number}","milestones_url":"https://api.github.com/repos/ARMmbed/htrun/milestones{/number}","notifications_url":"https://api.github.com/repos/ARMmbed/htrun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ARMmbed/htrun/labels{/name}","releases_url":"https://api.github.com/repos/ARMmbed/htrun/releases{/id}","deployments_url":"https://api.github.com/repos/ARMmbed/htrun/deployments","created_at":"2015-02-17T12:59:42Z","updated_at":"2017-05-31T18:10:03Z","pushed_at":"2017-05-31T19:13:24Z","git_url":"git://github.com/ARMmbed/htrun.git","ssh_url":"git@github.com:ARMmbed/htrun.git","clone_url":"https://github.com/ARMmbed/htrun.git","svn_url":"https://github.com/ARMmbed/htrun","homepage":"","size":626,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":8,"forks":20,"open_issues":8,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ARMmbed/htrun/pulls/160"},"html":{"href":"https://github.com/ARMmbed/htrun/pull/160"},"issue":{"href":"https://api.github.com/repos/ARMmbed/htrun/issues/160"},"comments":{"href":"https://api.github.com/repos/ARMmbed/htrun/issues/160/comments"},"review_comments":{"href":"https://api.github.com/repos/ARMmbed/htrun/pulls/160/comments"},"review_comment":{"href":"https://api.github.com/repos/ARMmbed/htrun/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ARMmbed/htrun/pulls/160/commits"},"statuses":{"href":"https://api.github.com/repos/ARMmbed/htrun/statuses/7a3c8fd8dfb13a03107b0914bc578f56d3bedbe5"}}}}
{"actor":{"display_login":"bridadan"}}