{"action":"created","comment":{"url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/comments/24011778","id":24011778,"diff_hunk":"@@ -0,0 +1,109 @@\n+'use strict';\n+\n+var childProcess = require('child_process');\n+var async = require('async');\n+var notif = require('./Notifcations');\n+var path = require('path');\n+var logger = require('log4js').getLogger('CloudifyCLI');\n+\n+var Virtualenv = function() {\n+\n+    /**\n+     * Initialize virtualenv\n+     * * *\n+     * @param {object} options - cmmander options\n+     * @param {function} fnCallback\n+     */\n+    function init(options, fnCallback) {\n+        if(options.env) {\n+            async.waterfall([\n+\n+                function(callback) {\n+                    notif.info('Initialize virtual environment...')\n+                    initEnvironment(options.prefix, function(err){\n+                        if(err) {\n+                            notif.faild('Initialize failed.');\n+                        }\n+                        else {\n+                            notif.ok('Initialize success.');\n+                            callback(null);\n+                        }\n+                    });\n+                }\n+\n+            ], fnCallback);\n+        }\n+        else {\n+            fnCallback(null);\n+        }\n+    }\n+\n+    /**\n+     * Initialize environment\n+     * * * \n+     * @param {string} env - environment name\n+     * @param {function} callback\n+     */\n+    function initEnvironment(env, callback) {\n+        var exec = childProcess.spawn('virtualenv', [env]);\n+\n+        exec.stdout.on('data', function (data) {\n+            logger.trace('stdout: ' + data);\n+        });\n+\n+        exec.stderr.on('data', function (data) {\n+            logger.trace('stderr: ' + data);\n+        });\n+\n+        exec.on('close', function (code) {\n+            callback(code !== 0 ? true : null);\n+            exec.stdin.end();\n+        });\n+    }\n+    \n+    function spawn(cmd, options, args, callback) {\n+        var stdout;\n+        var stderr;\n+        \n+        if(typeof(args) === 'function') {\n+            callback = args;\n+            args = {};\n+        }\n+\n+        switch(options.env) {\n+            case true:\n+                var exec = childProcess.spawn('bash', ['-c', 'source ' + path.resolve(options.prefix) + '/bin/activate; ' + cmd], args || {});","path":"lib/models/Virtualenv.js","position":75,"original_position":75,"commit_id":"a95d1c3e78614ad3ab3f31cf1da2cfe1f5dc6c6a","original_commit_id":"a95d1c3e78614ad3ab3f31cf1da2cfe1f5dc6c6a","user":{"login":"guy-mograbi-at-gigaspaces","id":2772271,"avatar_url":"https://avatars.githubusercontent.com/u/2772271?v=3","gravatar_id":"","url":"https://api.github.com/users/guy-mograbi-at-gigaspaces","html_url":"https://github.com/guy-mograbi-at-gigaspaces","followers_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/followers","following_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/following{/other_user}","gists_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/gists{/gist_id}","starred_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/subscriptions","organizations_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/orgs","repos_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/repos","events_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/events{/privacy}","received_events_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/received_events","type":"User","site_admin":false},"body":"need to check if prefix is defined. \r\ntrue that we fail in command parser if it does not, but every function should revalidate. ","created_at":"2015-02-03T15:38:56Z","updated_at":"2015-02-03T15:38:56Z","html_url":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer/pull/8#discussion_r24011778","pull_request_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/comments/24011778"},"html":{"href":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer/pull/8#discussion_r24011778"},"pull_request":{"href":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/8","id":28555016,"html_url":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer/pull/8","diff_url":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer/pull/8.diff","patch_url":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer/pull/8.patch","issue_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/issues/8","number":8,"state":"open","locked":false,"title":"Create virtualenv as default","user":{"login":"itsikm","id":4673361,"avatar_url":"https://avatars.githubusercontent.com/u/4673361?v=3","gravatar_id":"","url":"https://api.github.com/users/itsikm","html_url":"https://github.com/itsikm","followers_url":"https://api.github.com/users/itsikm/followers","following_url":"https://api.github.com/users/itsikm/following{/other_user}","gists_url":"https://api.github.com/users/itsikm/gists{/gist_id}","starred_url":"https://api.github.com/users/itsikm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itsikm/subscriptions","organizations_url":"https://api.github.com/users/itsikm/orgs","repos_url":"https://api.github.com/users/itsikm/repos","events_url":"https://api.github.com/users/itsikm/events{/privacy}","received_events_url":"https://api.github.com/users/itsikm/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-03T14:15:00Z","updated_at":"2015-02-03T15:38:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"922297db023adf82f301abf13efb88473b283d05","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/8/commits","review_comments_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/8/comments","review_comment_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/comments/{number}","comments_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/issues/8/comments","statuses_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/statuses/a95d1c3e78614ad3ab3f31cf1da2cfe1f5dc6c6a","head":{"label":"guy-mograbi-at-gigaspaces:create-virtualenv-as-default","ref":"create-virtualenv-as-default","sha":"a95d1c3e78614ad3ab3f31cf1da2cfe1f5dc6c6a","user":{"login":"guy-mograbi-at-gigaspaces","id":2772271,"avatar_url":"https://avatars.githubusercontent.com/u/2772271?v=3","gravatar_id":"","url":"https://api.github.com/users/guy-mograbi-at-gigaspaces","html_url":"https://github.com/guy-mograbi-at-gigaspaces","followers_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/followers","following_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/following{/other_user}","gists_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/gists{/gist_id}","starred_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/subscriptions","organizations_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/orgs","repos_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/repos","events_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/events{/privacy}","received_events_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/received_events","type":"User","site_admin":false},"repo":{"id":29309472,"name":"cloudify-installer","full_name":"guy-mograbi-at-gigaspaces/cloudify-installer","owner":{"login":"guy-mograbi-at-gigaspaces","id":2772271,"avatar_url":"https://avatars.githubusercontent.com/u/2772271?v=3","gravatar_id":"","url":"https://api.github.com/users/guy-mograbi-at-gigaspaces","html_url":"https://github.com/guy-mograbi-at-gigaspaces","followers_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/followers","following_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/following{/other_user}","gists_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/gists{/gist_id}","starred_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/subscriptions","organizations_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/orgs","repos_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/repos","events_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/events{/privacy}","received_events_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer","description":"a node tool to easily install cloudify and other goods","fork":false,"url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer","forks_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/forks","keys_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/teams","hooks_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/hooks","issue_events_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/issues/events{/number}","events_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/events","assignees_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/assignees{/user}","branches_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/branches{/branch}","tags_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/tags","blobs_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/git/refs{/sha}","trees_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/statuses/{sha}","languages_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/languages","stargazers_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/stargazers","contributors_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/contributors","subscribers_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/subscribers","subscription_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/subscription","commits_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/commits{/sha}","git_commits_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/git/commits{/sha}","comments_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/comments{/number}","issue_comment_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/issues/comments/{number}","contents_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/contents/{+path}","compare_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/merges","archive_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/downloads","issues_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/issues{/number}","pulls_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls{/number}","milestones_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/milestones{/number}","notifications_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/labels{/name}","releases_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/releases{/id}","created_at":"2015-01-15T17:39:24Z","updated_at":"2015-01-22T08:44:08Z","pushed_at":"2015-02-03T14:14:50Z","git_url":"git://github.com/guy-mograbi-at-gigaspaces/cloudify-installer.git","ssh_url":"git@github.com:guy-mograbi-at-gigaspaces/cloudify-installer.git","clone_url":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer.git","svn_url":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer","homepage":null,"size":336,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"guy-mograbi-at-gigaspaces:master","ref":"master","sha":"a6e168adffa760f5726324ccae86e7c23158708d","user":{"login":"guy-mograbi-at-gigaspaces","id":2772271,"avatar_url":"https://avatars.githubusercontent.com/u/2772271?v=3","gravatar_id":"","url":"https://api.github.com/users/guy-mograbi-at-gigaspaces","html_url":"https://github.com/guy-mograbi-at-gigaspaces","followers_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/followers","following_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/following{/other_user}","gists_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/gists{/gist_id}","starred_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/subscriptions","organizations_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/orgs","repos_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/repos","events_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/events{/privacy}","received_events_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/received_events","type":"User","site_admin":false},"repo":{"id":29309472,"name":"cloudify-installer","full_name":"guy-mograbi-at-gigaspaces/cloudify-installer","owner":{"login":"guy-mograbi-at-gigaspaces","id":2772271,"avatar_url":"https://avatars.githubusercontent.com/u/2772271?v=3","gravatar_id":"","url":"https://api.github.com/users/guy-mograbi-at-gigaspaces","html_url":"https://github.com/guy-mograbi-at-gigaspaces","followers_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/followers","following_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/following{/other_user}","gists_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/gists{/gist_id}","starred_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/subscriptions","organizations_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/orgs","repos_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/repos","events_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/events{/privacy}","received_events_url":"https://api.github.com/users/guy-mograbi-at-gigaspaces/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer","description":"a node tool to easily install cloudify and other goods","fork":false,"url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer","forks_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/forks","keys_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/teams","hooks_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/hooks","issue_events_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/issues/events{/number}","events_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/events","assignees_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/assignees{/user}","branches_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/branches{/branch}","tags_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/tags","blobs_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/git/refs{/sha}","trees_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/statuses/{sha}","languages_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/languages","stargazers_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/stargazers","contributors_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/contributors","subscribers_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/subscribers","subscription_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/subscription","commits_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/commits{/sha}","git_commits_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/git/commits{/sha}","comments_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/comments{/number}","issue_comment_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/issues/comments/{number}","contents_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/contents/{+path}","compare_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/merges","archive_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/downloads","issues_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/issues{/number}","pulls_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls{/number}","milestones_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/milestones{/number}","notifications_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/labels{/name}","releases_url":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/releases{/id}","created_at":"2015-01-15T17:39:24Z","updated_at":"2015-01-22T08:44:08Z","pushed_at":"2015-02-03T14:14:50Z","git_url":"git://github.com/guy-mograbi-at-gigaspaces/cloudify-installer.git","ssh_url":"git@github.com:guy-mograbi-at-gigaspaces/cloudify-installer.git","clone_url":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer.git","svn_url":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer","homepage":null,"size":336,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/8"},"html":{"href":"https://github.com/guy-mograbi-at-gigaspaces/cloudify-installer/pull/8"},"issue":{"href":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/issues/8"},"comments":{"href":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/guy-mograbi-at-gigaspaces/cloudify-installer/statuses/a95d1c3e78614ad3ab3f31cf1da2cfe1f5dc6c6a"}}}}