{"action":"created","comment":{"url":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/comments/64358458","id":64358458,"diff_hunk":"@@ -0,0 +1,157 @@\n+\n+require \"yast\"\n+\n+module Yast\n+  class Debugger\n+    class << self\n+      include Yast::Logger\n+      include Yast::UIShortcuts\n+\n+      # Start the Ruby debugger. It handles the current UI mode and displays\n+      # an user request if the debugger front-end needs to be started manually.\n+      # @param [Boolean] remote if set to true the server is accesible from network.\n+      #   By default the debugger can connect only from the local machine, not from\n+      #   the network. If you need remote debugging then enable it.\n+      #   WARNING: There is no authentication, everybody can connect to\n+      #   the debugger! Use only in a trusted network as this is actually\n+      #   a backdoor to the system! For secure connection use SSH and start\n+      #   the debugger locally after connecting via SSH.\n+      # @param [Fixnum] port the port number where the debugger server will\n+      #   listen to\n+      # @param [Boolean] start_client autostart the debugger client\n+      #   (ignored in remote debugging)\n+      # @example Start the debugger with default settings:\n+      #   require \"yast/debugger\"\n+      #   Yast::Debugger.start\n+      # @example When using the debugger temporary you can use just simple:\n+      #   require \"byebug\"\n+      #   byebug\n+      def start(remote: false, port: 3344, start_client: true)\n+        begin\n+          require \"byebug\"\n+          require \"byebug/core\"\n+        rescue LoadError\n+          # catch loading error, the debugger is optional (might not be present)\n+          Yast.import \"Report\"\n+          Report.Error(format(\"Cannot load the Ruby debugger.\\n\" \\\n+            \"Make sure '%s' Ruby gem is installed.\") % \"byebug\")\n+          return\n+        end\n+\n+        popup = false\n+\n+        # do not start the server if it is already running\n+        if Byebug.started?\n+          log.warn \"The debugger is already running at port #{Byebug.actual_port}\"\n+          log.warn \"Skipping the server setup\"\n+        else\n+          Yast.import \"UI\"\n+          wait = false\n+          if UI.TextMode || remote || !start_client\n+            # in textmode or in remote mode ask the user to start\n+            # the debugger client manually\n+            UI.OpenDialog(Label(debugger_message(remote, port)))\n+            popup = true\n+          else\n+            # in GUI open an xterm session with the debugger\n+            start_gui_session(port)\n+            # wait a bit to get the server ready (to avoid \"Broken pipe\" error)\n+            # FIXME: looks like a race condition inside byebug itself...\n+            wait = true\n+          end\n+\n+          # start the server and wait for connection\n+          start_server(remote, port, wait)","path":"src/ruby/yast/debugger.rb","position":64,"original_position":64,"commit_id":"6736566169fa1e71133f54a507b4659abb01e899","original_commit_id":"6736566169fa1e71133f54a507b4659abb01e899","user":{"login":"jreidinger","id":478871,"avatar_url":"https://avatars.githubusercontent.com/u/478871?v=3","gravatar_id":"","url":"https://api.github.com/users/jreidinger","html_url":"https://github.com/jreidinger","followers_url":"https://api.github.com/users/jreidinger/followers","following_url":"https://api.github.com/users/jreidinger/following{/other_user}","gists_url":"https://api.github.com/users/jreidinger/gists{/gist_id}","starred_url":"https://api.github.com/users/jreidinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreidinger/subscriptions","organizations_url":"https://api.github.com/users/jreidinger/orgs","repos_url":"https://api.github.com/users/jreidinger/repos","events_url":"https://api.github.com/users/jreidinger/events{/privacy}","received_events_url":"https://api.github.com/users/jreidinger/received_events","type":"User","site_admin":false},"body":"wait parameter looks a bit weird, as I interpret it as wait for connection. and it is also boolean parameter, so maybe named parameter will be nicer.","created_at":"2016-05-24T09:33:37Z","updated_at":"2016-05-24T09:33:37Z","html_url":"https://github.com/yast/yast-ruby-bindings/pull/167#discussion_r64358458","pull_request_url":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/167","_links":{"self":{"href":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/comments/64358458"},"html":{"href":"https://github.com/yast/yast-ruby-bindings/pull/167#discussion_r64358458"},"pull_request":{"href":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/167"}}},"pull_request":{"url":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/167","id":71063220,"html_url":"https://github.com/yast/yast-ruby-bindings/pull/167","diff_url":"https://github.com/yast/yast-ruby-bindings/pull/167.diff","patch_url":"https://github.com/yast/yast-ruby-bindings/pull/167.patch","issue_url":"https://api.github.com/repos/yast/yast-ruby-bindings/issues/167","number":167,"state":"open","locked":false,"title":"Debugger support","user":{"login":"lslezak","id":907998,"avatar_url":"https://avatars.githubusercontent.com/u/907998?v=3","gravatar_id":"","url":"https://api.github.com/users/lslezak","html_url":"https://github.com/lslezak","followers_url":"https://api.github.com/users/lslezak/followers","following_url":"https://api.github.com/users/lslezak/following{/other_user}","gists_url":"https://api.github.com/users/lslezak/gists{/gist_id}","starred_url":"https://api.github.com/users/lslezak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lslezak/subscriptions","organizations_url":"https://api.github.com/users/lslezak/orgs","repos_url":"https://api.github.com/users/lslezak/repos","events_url":"https://api.github.com/users/lslezak/events{/privacy}","received_events_url":"https://api.github.com/users/lslezak/received_events","type":"User","site_admin":false},"body":"- Added `yast/debugger` for generic handling of the Ruby debugger (to be used in the installer, see [FATE#318421](https://fate.suse.com/318421), the installer part is implemented in this PR: https://github.com/yast/yast-installation/pull/379).\r\n\r\n## Bonus \r\n\r\n- Allow running the debugger from the generic crash handler, see the screenshots below.\r\n\r\n### Screenshots\r\n\r\nThe original generic crash handler displays a popup like this:\r\n\r\n![debugger_crash_orig_popup](https://cloud.githubusercontent.com/assets/907998/15471622/35f81882-20f7-11e6-9c04-c0bce84731fe.png)\r\n\r\nWith this patch when the `byebug` Ruby gem is installed it displays this:\r\n\r\n![debugger_crash_popup](https://cloud.githubusercontent.com/assets/907998/15471891/a4a022f6-20f8-11e6-89b3-a7b0001977af.png)\r\n\r\n\r\nWhich when confirmed starts the debug session in a new `xterm` window:\r\n\r\n![debugger_crash_started](https://cloud.githubusercontent.com/assets/907998/15471660/70d2ff26-20f7-11e6-974c-c31577269c79.png)\r\n\r\nIn the text mode we cannot start the `xterm` session automatically, you have to start the debugger front end manually:\r\n\r\n![debugger_crash_popup_ncurses](https://cloud.githubusercontent.com/assets/907998/15471783/1a857ae4-20f8-11e6-8ec3-b9c6770cdbeb.png)\r\n","created_at":"2016-05-23T13:43:25Z","updated_at":"2016-05-24T09:33:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b43bb4d08c78164c4320a2c7a85f8a8fa8ba821","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/167/commits","review_comments_url":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/167/comments","review_comment_url":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yast/yast-ruby-bindings/issues/167/comments","statuses_url":"https://api.github.com/repos/yast/yast-ruby-bindings/statuses/6736566169fa1e71133f54a507b4659abb01e899","head":{"label":"yast:debugger","ref":"debugger","sha":"6736566169fa1e71133f54a507b4659abb01e899","user":{"login":"yast","id":909990,"avatar_url":"https://avatars.githubusercontent.com/u/909990?v=3","gravatar_id":"","url":"https://api.github.com/users/yast","html_url":"https://github.com/yast","followers_url":"https://api.github.com/users/yast/followers","following_url":"https://api.github.com/users/yast/following{/other_user}","gists_url":"https://api.github.com/users/yast/gists{/gist_id}","starred_url":"https://api.github.com/users/yast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yast/subscriptions","organizations_url":"https://api.github.com/users/yast/orgs","repos_url":"https://api.github.com/users/yast/repos","events_url":"https://api.github.com/users/yast/events{/privacy}","received_events_url":"https://api.github.com/users/yast/received_events","type":"Organization","site_admin":false},"repo":{"id":4371567,"name":"yast-ruby-bindings","full_name":"yast/yast-ruby-bindings","owner":{"login":"yast","id":909990,"avatar_url":"https://avatars.githubusercontent.com/u/909990?v=3","gravatar_id":"","url":"https://api.github.com/users/yast","html_url":"https://github.com/yast","followers_url":"https://api.github.com/users/yast/followers","following_url":"https://api.github.com/users/yast/following{/other_user}","gists_url":"https://api.github.com/users/yast/gists{/gist_id}","starred_url":"https://api.github.com/users/yast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yast/subscriptions","organizations_url":"https://api.github.com/users/yast/orgs","repos_url":"https://api.github.com/users/yast/repos","events_url":"https://api.github.com/users/yast/events{/privacy}","received_events_url":"https://api.github.com/users/yast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yast/yast-ruby-bindings","description":"YaST module ruby-bindings","fork":false,"url":"https://api.github.com/repos/yast/yast-ruby-bindings","forks_url":"https://api.github.com/repos/yast/yast-ruby-bindings/forks","keys_url":"https://api.github.com/repos/yast/yast-ruby-bindings/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yast/yast-ruby-bindings/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yast/yast-ruby-bindings/teams","hooks_url":"https://api.github.com/repos/yast/yast-ruby-bindings/hooks","issue_events_url":"https://api.github.com/repos/yast/yast-ruby-bindings/issues/events{/number}","events_url":"https://api.github.com/repos/yast/yast-ruby-bindings/events","assignees_url":"https://api.github.com/repos/yast/yast-ruby-bindings/assignees{/user}","branches_url":"https://api.github.com/repos/yast/yast-ruby-bindings/branches{/branch}","tags_url":"https://api.github.com/repos/yast/yast-ruby-bindings/tags","blobs_url":"https://api.github.com/repos/yast/yast-ruby-bindings/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yast/yast-ruby-bindings/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yast/yast-ruby-bindings/git/refs{/sha}","trees_url":"https://api.github.com/repos/yast/yast-ruby-bindings/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yast/yast-ruby-bindings/statuses/{sha}","languages_url":"https://api.github.com/repos/yast/yast-ruby-bindings/languages","stargazers_url":"https://api.github.com/repos/yast/yast-ruby-bindings/stargazers","contributors_url":"https://api.github.com/repos/yast/yast-ruby-bindings/contributors","subscribers_url":"https://api.github.com/repos/yast/yast-ruby-bindings/subscribers","subscription_url":"https://api.github.com/repos/yast/yast-ruby-bindings/subscription","commits_url":"https://api.github.com/repos/yast/yast-ruby-bindings/commits{/sha}","git_commits_url":"https://api.github.com/repos/yast/yast-ruby-bindings/git/commits{/sha}","comments_url":"https://api.github.com/repos/yast/yast-ruby-bindings/comments{/number}","issue_comment_url":"https://api.github.com/repos/yast/yast-ruby-bindings/issues/comments{/number}","contents_url":"https://api.github.com/repos/yast/yast-ruby-bindings/contents/{+path}","compare_url":"https://api.github.com/repos/yast/yast-ruby-bindings/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yast/yast-ruby-bindings/merges","archive_url":"https://api.github.com/repos/yast/yast-ruby-bindings/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yast/yast-ruby-bindings/downloads","issues_url":"https://api.github.com/repos/yast/yast-ruby-bindings/issues{/number}","pulls_url":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls{/number}","milestones_url":"https://api.github.com/repos/yast/yast-ruby-bindings/milestones{/number}","notifications_url":"https://api.github.com/repos/yast/yast-ruby-bindings/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yast/yast-ruby-bindings/labels{/name}","releases_url":"https://api.github.com/repos/yast/yast-ruby-bindings/releases{/id}","deployments_url":"https://api.github.com/repos/yast/yast-ruby-bindings/deployments","created_at":"2012-05-18T17:12:39Z","updated_at":"2016-01-12T14:08:05Z","pushed_at":"2016-05-24T07:59:19Z","git_url":"git://github.com/yast/yast-ruby-bindings.git","ssh_url":"git@github.com:yast/yast-ruby-bindings.git","clone_url":"https://github.com/yast/yast-ruby-bindings.git","svn_url":"https://github.com/yast/yast-ruby-bindings","homepage":"http://en.opensuse.org/Portal:YaST","size":1195,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":10,"forks":10,"open_issues":10,"watchers":2,"default_branch":"master"}},"base":{"label":"yast:master","ref":"master","sha":"b73d72e8e1634e24b2671fd33019d4798ef8210a","user":{"login":"yast","id":909990,"avatar_url":"https://avatars.githubusercontent.com/u/909990?v=3","gravatar_id":"","url":"https://api.github.com/users/yast","html_url":"https://github.com/yast","followers_url":"https://api.github.com/users/yast/followers","following_url":"https://api.github.com/users/yast/following{/other_user}","gists_url":"https://api.github.com/users/yast/gists{/gist_id}","starred_url":"https://api.github.com/users/yast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yast/subscriptions","organizations_url":"https://api.github.com/users/yast/orgs","repos_url":"https://api.github.com/users/yast/repos","events_url":"https://api.github.com/users/yast/events{/privacy}","received_events_url":"https://api.github.com/users/yast/received_events","type":"Organization","site_admin":false},"repo":{"id":4371567,"name":"yast-ruby-bindings","full_name":"yast/yast-ruby-bindings","owner":{"login":"yast","id":909990,"avatar_url":"https://avatars.githubusercontent.com/u/909990?v=3","gravatar_id":"","url":"https://api.github.com/users/yast","html_url":"https://github.com/yast","followers_url":"https://api.github.com/users/yast/followers","following_url":"https://api.github.com/users/yast/following{/other_user}","gists_url":"https://api.github.com/users/yast/gists{/gist_id}","starred_url":"https://api.github.com/users/yast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yast/subscriptions","organizations_url":"https://api.github.com/users/yast/orgs","repos_url":"https://api.github.com/users/yast/repos","events_url":"https://api.github.com/users/yast/events{/privacy}","received_events_url":"https://api.github.com/users/yast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yast/yast-ruby-bindings","description":"YaST module ruby-bindings","fork":false,"url":"https://api.github.com/repos/yast/yast-ruby-bindings","forks_url":"https://api.github.com/repos/yast/yast-ruby-bindings/forks","keys_url":"https://api.github.com/repos/yast/yast-ruby-bindings/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yast/yast-ruby-bindings/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yast/yast-ruby-bindings/teams","hooks_url":"https://api.github.com/repos/yast/yast-ruby-bindings/hooks","issue_events_url":"https://api.github.com/repos/yast/yast-ruby-bindings/issues/events{/number}","events_url":"https://api.github.com/repos/yast/yast-ruby-bindings/events","assignees_url":"https://api.github.com/repos/yast/yast-ruby-bindings/assignees{/user}","branches_url":"https://api.github.com/repos/yast/yast-ruby-bindings/branches{/branch}","tags_url":"https://api.github.com/repos/yast/yast-ruby-bindings/tags","blobs_url":"https://api.github.com/repos/yast/yast-ruby-bindings/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yast/yast-ruby-bindings/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yast/yast-ruby-bindings/git/refs{/sha}","trees_url":"https://api.github.com/repos/yast/yast-ruby-bindings/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yast/yast-ruby-bindings/statuses/{sha}","languages_url":"https://api.github.com/repos/yast/yast-ruby-bindings/languages","stargazers_url":"https://api.github.com/repos/yast/yast-ruby-bindings/stargazers","contributors_url":"https://api.github.com/repos/yast/yast-ruby-bindings/contributors","subscribers_url":"https://api.github.com/repos/yast/yast-ruby-bindings/subscribers","subscription_url":"https://api.github.com/repos/yast/yast-ruby-bindings/subscription","commits_url":"https://api.github.com/repos/yast/yast-ruby-bindings/commits{/sha}","git_commits_url":"https://api.github.com/repos/yast/yast-ruby-bindings/git/commits{/sha}","comments_url":"https://api.github.com/repos/yast/yast-ruby-bindings/comments{/number}","issue_comment_url":"https://api.github.com/repos/yast/yast-ruby-bindings/issues/comments{/number}","contents_url":"https://api.github.com/repos/yast/yast-ruby-bindings/contents/{+path}","compare_url":"https://api.github.com/repos/yast/yast-ruby-bindings/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yast/yast-ruby-bindings/merges","archive_url":"https://api.github.com/repos/yast/yast-ruby-bindings/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yast/yast-ruby-bindings/downloads","issues_url":"https://api.github.com/repos/yast/yast-ruby-bindings/issues{/number}","pulls_url":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls{/number}","milestones_url":"https://api.github.com/repos/yast/yast-ruby-bindings/milestones{/number}","notifications_url":"https://api.github.com/repos/yast/yast-ruby-bindings/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yast/yast-ruby-bindings/labels{/name}","releases_url":"https://api.github.com/repos/yast/yast-ruby-bindings/releases{/id}","deployments_url":"https://api.github.com/repos/yast/yast-ruby-bindings/deployments","created_at":"2012-05-18T17:12:39Z","updated_at":"2016-01-12T14:08:05Z","pushed_at":"2016-05-24T07:59:19Z","git_url":"git://github.com/yast/yast-ruby-bindings.git","ssh_url":"git@github.com:yast/yast-ruby-bindings.git","clone_url":"https://github.com/yast/yast-ruby-bindings.git","svn_url":"https://github.com/yast/yast-ruby-bindings","homepage":"http://en.opensuse.org/Portal:YaST","size":1195,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":10,"forks":10,"open_issues":10,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/167"},"html":{"href":"https://github.com/yast/yast-ruby-bindings/pull/167"},"issue":{"href":"https://api.github.com/repos/yast/yast-ruby-bindings/issues/167"},"comments":{"href":"https://api.github.com/repos/yast/yast-ruby-bindings/issues/167/comments"},"review_comments":{"href":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/167/comments"},"review_comment":{"href":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yast/yast-ruby-bindings/pulls/167/commits"},"statuses":{"href":"https://api.github.com/repos/yast/yast-ruby-bindings/statuses/6736566169fa1e71133f54a507b4659abb01e899"}}}}
{"actor":{"display_login":"jreidinger"}}