{"action":"created","comment":{"url":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/comments/184791429","pull_request_review_id":116064539,"id":184791429,"diff_hunk":"@@ -0,0 +1,108 @@\n+from encoded.commands.import_data import (basic_auth, remote_app)\n+from pyramid import paster\n+from urllib.parse import urlparse\n+from multiprocessing.pool import ThreadPool\n+import requests, logging, json, os\n+\n+EPILOG = __doc__\n+\n+'''\n+Use this here tool to export something like a collection of Pages to inserts.\n+This tool be wicked flexible so for best results, make sure to craft a good search query, otherwise you'll crash things if you try to export\n+something like /search/?type=All&limit=all (seriously, this command does NOT use streaming, it WILL load things into RAM).\n+\n+Recommended examples:\n+  - bin/export-data \"https://data.4dnucleome.org/search/?type=Page&limit=all\" -u ACCESS_KEY_ID -p ACCESS_KEY_SECRET > new_page_inserts_file.json\n+  - bin/export-data \"https://data.4dnucleome.org/search/?type=StaticSection&limit=all\" -u ACCESS_KEY_ID -p ACCESS_KEY_SECRET > new_static_section_inserts_file.json\n+\n+This has not been tested, but theoretically should be able to pipe inserts from export_data to import_data (e.g. transfer data to different server) for __small__ amounts of data (due to lack of streaming).\n+'''\n+\n+\n+def run(search_url, username='', password=''):\n+\n+    url = urlparse(search_url)\n+\n+    if url.scheme in ('http', 'https') and '/search/?type=' in search_url:\n+        base = url.scheme + '://' + url.netloc\n+        auth_header = basic_auth(username, password)\n+    else:\n+        raise Exception('Invalid URL supplied.')\n+\n+    # Loading app will have configured from config file. Reconfigure here:\n+    logging.getLogger('encoded').setLevel(logging.INFO)\n+    logging.getLogger('wsgi').setLevel(logging.WARNING)\n+    logger = logging.getLogger(__name__)\n+    logger.setLevel(logging.INFO)\n+\n+    auth_to_use = (username, password) if username and password else None\n+\n+    test_app = remote_app(base, username, password)","path":"src/encoded/commands/export_data.py","position":40,"original_position":40,"commit_id":"097e066f1a3b03920b0591fba29665e03b6df6ed","original_commit_id":"097e066f1a3b03920b0591fba29665e03b6df6ed","user":{"login":"codacy-bot","id":19940114,"avatar_url":"https://avatars1.githubusercontent.com/u/19940114?v=4","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://app.codacy.com/assets/images/favicon.png) Issue found: [Unused variable 'test_app'](https://app.codacy.com/app/4dn/fourfront/pullRequest?prid=1591187)","created_at":"2018-04-27T19:56:03Z","updated_at":"2018-04-27T19:56:03Z","html_url":"https://github.com/4dn-dcic/fourfront/pull/771#discussion_r184791429","pull_request_url":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/771","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/comments/184791429"},"html":{"href":"https://github.com/4dn-dcic/fourfront/pull/771#discussion_r184791429"},"pull_request":{"href":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/771"}}},"pull_request":{"url":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/771","id":184695048,"html_url":"https://github.com/4dn-dcic/fourfront/pull/771","diff_url":"https://github.com/4dn-dcic/fourfront/pull/771.diff","patch_url":"https://github.com/4dn-dcic/fourfront/pull/771.patch","issue_url":"https://api.github.com/repos/4dn-dcic/fourfront/issues/771","number":771,"state":"open","locked":false,"title":"(Approaching Readiness) Static Pages Hierarchy & DropDown","user":{"login":"alexkb0009","id":10673737,"avatar_url":"https://avatars2.githubusercontent.com/u/10673737?v=4","gravatar_id":"","url":"https://api.github.com/users/alexkb0009","html_url":"https://github.com/alexkb0009","followers_url":"https://api.github.com/users/alexkb0009/followers","following_url":"https://api.github.com/users/alexkb0009/following{/other_user}","gists_url":"https://api.github.com/users/alexkb0009/gists{/gist_id}","starred_url":"https://api.github.com/users/alexkb0009/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexkb0009/subscriptions","organizations_url":"https://api.github.com/users/alexkb0009/orgs","repos_url":"https://api.github.com/users/alexkb0009/repos","events_url":"https://api.github.com/users/alexkb0009/events{/privacy}","received_events_url":"https://api.github.com/users/alexkb0009/received_events","type":"User","site_admin":false},"body":"Lots of new features.\r\n\r\nRemaining ToDos include updating [Static Page Documentation](https://github.com/4dn-dcic/fourfront/blob/master/docs/static-pages.md) & Tangential Submission View things.\r\n\r\nWorking Draft of:\r\n\r\n## Best Practices\r\n\r\n- DO split Pages into multiple StaticSections with proper title for each, if possible, rather than having Page that has just one big long Markdown section/file.\r\n   - This will allow each section to be re-used in other places & apply permissions to each section.\r\n   - If there is only one or less sections with a title (e.g. could have multiple sections all with no titles or just one big long section), then the `##` (h2) headers get promoted as if they were Section headers in TableOfContents. However, styling within the page itself will remain as Markdown h2 header (not section header). H1 (`#`) headers are reserved for Page titles and are not currently supported within (our parsing of) Markdown.\r\n   - If have *2+* static sections with titles, all sections and their titles — even if nonexistent — will be displayed in TableOfContents. If there’s a section for which title doesn’t exist, will default to “Table of Content Entry”, e.g. [this example](https://gyazo.com/e3f718273d5d46e9ffcab884b9a36fa3) containing 4 sections, with titles for just two of them.\r\n     - **Update**: Default, if no title on Section, is now (JS equivalent of) `\" \".join([ word.capitalize() for word in section.link.split(\"-\") ])` where section.link is last bit of StaticSection name (e.g. “lorem-ipsum-1” => “Lorem Ipsum 1”)\r\n- If are going to edit Pages/Sections through Fourfront UI (rather than using a Markdown/text editor & then adding to inserts) — then is a good idea to keep inserts up-to-date in order to make local development + testing simpler as well as provide an extra source of backups.\r\n  - Our primary mission isn’t to maintain/support a custom content management system so having a concrete outside-of-db representation of static pages I think is desireable.\r\n  - There is now a command called `bin/export-data` which can be used to export Page and StaticSection inserts into JSON files. Examples:\r\n    ```bash\r\n    bin/export-data \"https://data.4dnucleome.org/search/?type=Page&limit=all\" -u ACCESS_KEY_ID -p ACCESS_KEY_SECRET > new_page_inserts_file.json\r\n    bin/export-data \"https://data.4dnucleome.org/search/?type=StaticSection&limit=all\" -u ACCESS_KEY_ID -p ACCESS_KEY_SECRET > new_static_section_inserts_file.json\r\n    ```","created_at":"2018-04-27T18:29:45Z","updated_at":"2018-04-27T19:56:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"678c988cfabd06dc7e6cd74bae2047fab75dafa5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/771/commits","review_comments_url":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/771/comments","review_comment_url":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/comments{/number}","comments_url":"https://api.github.com/repos/4dn-dcic/fourfront/issues/771/comments","statuses_url":"https://api.github.com/repos/4dn-dcic/fourfront/statuses/097e066f1a3b03920b0591fba29665e03b6df6ed","head":{"label":"4dn-dcic:static_pages","ref":"static_pages","sha":"097e066f1a3b03920b0591fba29665e03b6df6ed","user":{"login":"4dn-dcic","id":23222469,"avatar_url":"https://avatars3.githubusercontent.com/u/23222469?v=4","gravatar_id":"","url":"https://api.github.com/users/4dn-dcic","html_url":"https://github.com/4dn-dcic","followers_url":"https://api.github.com/users/4dn-dcic/followers","following_url":"https://api.github.com/users/4dn-dcic/following{/other_user}","gists_url":"https://api.github.com/users/4dn-dcic/gists{/gist_id}","starred_url":"https://api.github.com/users/4dn-dcic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4dn-dcic/subscriptions","organizations_url":"https://api.github.com/users/4dn-dcic/orgs","repos_url":"https://api.github.com/users/4dn-dcic/repos","events_url":"https://api.github.com/users/4dn-dcic/events{/privacy}","received_events_url":"https://api.github.com/users/4dn-dcic/received_events","type":"Organization","site_admin":false},"repo":{"id":58398322,"name":"fourfront","full_name":"4dn-dcic/fourfront","owner":{"login":"4dn-dcic","id":23222469,"avatar_url":"https://avatars3.githubusercontent.com/u/23222469?v=4","gravatar_id":"","url":"https://api.github.com/users/4dn-dcic","html_url":"https://github.com/4dn-dcic","followers_url":"https://api.github.com/users/4dn-dcic/followers","following_url":"https://api.github.com/users/4dn-dcic/following{/other_user}","gists_url":"https://api.github.com/users/4dn-dcic/gists{/gist_id}","starred_url":"https://api.github.com/users/4dn-dcic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4dn-dcic/subscriptions","organizations_url":"https://api.github.com/users/4dn-dcic/orgs","repos_url":"https://api.github.com/users/4dn-dcic/repos","events_url":"https://api.github.com/users/4dn-dcic/events{/privacy}","received_events_url":"https://api.github.com/users/4dn-dcic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/4dn-dcic/fourfront","description":"website for submitting and viewing genomic data","fork":false,"url":"https://api.github.com/repos/4dn-dcic/fourfront","forks_url":"https://api.github.com/repos/4dn-dcic/fourfront/forks","keys_url":"https://api.github.com/repos/4dn-dcic/fourfront/keys{/key_id}","collaborators_url":"https://api.github.com/repos/4dn-dcic/fourfront/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/4dn-dcic/fourfront/teams","hooks_url":"https://api.github.com/repos/4dn-dcic/fourfront/hooks","issue_events_url":"https://api.github.com/repos/4dn-dcic/fourfront/issues/events{/number}","events_url":"https://api.github.com/repos/4dn-dcic/fourfront/events","assignees_url":"https://api.github.com/repos/4dn-dcic/fourfront/assignees{/user}","branches_url":"https://api.github.com/repos/4dn-dcic/fourfront/branches{/branch}","tags_url":"https://api.github.com/repos/4dn-dcic/fourfront/tags","blobs_url":"https://api.github.com/repos/4dn-dcic/fourfront/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/4dn-dcic/fourfront/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/4dn-dcic/fourfront/git/refs{/sha}","trees_url":"https://api.github.com/repos/4dn-dcic/fourfront/git/trees{/sha}","statuses_url":"https://api.github.com/repos/4dn-dcic/fourfront/statuses/{sha}","languages_url":"https://api.github.com/repos/4dn-dcic/fourfront/languages","stargazers_url":"https://api.github.com/repos/4dn-dcic/fourfront/stargazers","contributors_url":"https://api.github.com/repos/4dn-dcic/fourfront/contributors","subscribers_url":"https://api.github.com/repos/4dn-dcic/fourfront/subscribers","subscription_url":"https://api.github.com/repos/4dn-dcic/fourfront/subscription","commits_url":"https://api.github.com/repos/4dn-dcic/fourfront/commits{/sha}","git_commits_url":"https://api.github.com/repos/4dn-dcic/fourfront/git/commits{/sha}","comments_url":"https://api.github.com/repos/4dn-dcic/fourfront/comments{/number}","issue_comment_url":"https://api.github.com/repos/4dn-dcic/fourfront/issues/comments{/number}","contents_url":"https://api.github.com/repos/4dn-dcic/fourfront/contents/{+path}","compare_url":"https://api.github.com/repos/4dn-dcic/fourfront/compare/{base}...{head}","merges_url":"https://api.github.com/repos/4dn-dcic/fourfront/merges","archive_url":"https://api.github.com/repos/4dn-dcic/fourfront/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/4dn-dcic/fourfront/downloads","issues_url":"https://api.github.com/repos/4dn-dcic/fourfront/issues{/number}","pulls_url":"https://api.github.com/repos/4dn-dcic/fourfront/pulls{/number}","milestones_url":"https://api.github.com/repos/4dn-dcic/fourfront/milestones{/number}","notifications_url":"https://api.github.com/repos/4dn-dcic/fourfront/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/4dn-dcic/fourfront/labels{/name}","releases_url":"https://api.github.com/repos/4dn-dcic/fourfront/releases{/id}","deployments_url":"https://api.github.com/repos/4dn-dcic/fourfront/deployments","created_at":"2016-05-09T18:19:56Z","updated_at":"2018-04-27T17:17:02Z","pushed_at":"2018-04-27T19:53:30Z","git_url":"git://github.com/4dn-dcic/fourfront.git","ssh_url":"git@github.com:4dn-dcic/fourfront.git","clone_url":"https://github.com/4dn-dcic/fourfront.git","svn_url":"https://github.com/4dn-dcic/fourfront","homepage":null,"size":196897,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":7,"watchers":5,"default_branch":"master"}},"base":{"label":"4dn-dcic:master","ref":"master","sha":"acc5a9b9af88689efaaf2a3c1b4a66d83025b4ee","user":{"login":"4dn-dcic","id":23222469,"avatar_url":"https://avatars3.githubusercontent.com/u/23222469?v=4","gravatar_id":"","url":"https://api.github.com/users/4dn-dcic","html_url":"https://github.com/4dn-dcic","followers_url":"https://api.github.com/users/4dn-dcic/followers","following_url":"https://api.github.com/users/4dn-dcic/following{/other_user}","gists_url":"https://api.github.com/users/4dn-dcic/gists{/gist_id}","starred_url":"https://api.github.com/users/4dn-dcic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4dn-dcic/subscriptions","organizations_url":"https://api.github.com/users/4dn-dcic/orgs","repos_url":"https://api.github.com/users/4dn-dcic/repos","events_url":"https://api.github.com/users/4dn-dcic/events{/privacy}","received_events_url":"https://api.github.com/users/4dn-dcic/received_events","type":"Organization","site_admin":false},"repo":{"id":58398322,"name":"fourfront","full_name":"4dn-dcic/fourfront","owner":{"login":"4dn-dcic","id":23222469,"avatar_url":"https://avatars3.githubusercontent.com/u/23222469?v=4","gravatar_id":"","url":"https://api.github.com/users/4dn-dcic","html_url":"https://github.com/4dn-dcic","followers_url":"https://api.github.com/users/4dn-dcic/followers","following_url":"https://api.github.com/users/4dn-dcic/following{/other_user}","gists_url":"https://api.github.com/users/4dn-dcic/gists{/gist_id}","starred_url":"https://api.github.com/users/4dn-dcic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4dn-dcic/subscriptions","organizations_url":"https://api.github.com/users/4dn-dcic/orgs","repos_url":"https://api.github.com/users/4dn-dcic/repos","events_url":"https://api.github.com/users/4dn-dcic/events{/privacy}","received_events_url":"https://api.github.com/users/4dn-dcic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/4dn-dcic/fourfront","description":"website for submitting and viewing genomic data","fork":false,"url":"https://api.github.com/repos/4dn-dcic/fourfront","forks_url":"https://api.github.com/repos/4dn-dcic/fourfront/forks","keys_url":"https://api.github.com/repos/4dn-dcic/fourfront/keys{/key_id}","collaborators_url":"https://api.github.com/repos/4dn-dcic/fourfront/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/4dn-dcic/fourfront/teams","hooks_url":"https://api.github.com/repos/4dn-dcic/fourfront/hooks","issue_events_url":"https://api.github.com/repos/4dn-dcic/fourfront/issues/events{/number}","events_url":"https://api.github.com/repos/4dn-dcic/fourfront/events","assignees_url":"https://api.github.com/repos/4dn-dcic/fourfront/assignees{/user}","branches_url":"https://api.github.com/repos/4dn-dcic/fourfront/branches{/branch}","tags_url":"https://api.github.com/repos/4dn-dcic/fourfront/tags","blobs_url":"https://api.github.com/repos/4dn-dcic/fourfront/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/4dn-dcic/fourfront/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/4dn-dcic/fourfront/git/refs{/sha}","trees_url":"https://api.github.com/repos/4dn-dcic/fourfront/git/trees{/sha}","statuses_url":"https://api.github.com/repos/4dn-dcic/fourfront/statuses/{sha}","languages_url":"https://api.github.com/repos/4dn-dcic/fourfront/languages","stargazers_url":"https://api.github.com/repos/4dn-dcic/fourfront/stargazers","contributors_url":"https://api.github.com/repos/4dn-dcic/fourfront/contributors","subscribers_url":"https://api.github.com/repos/4dn-dcic/fourfront/subscribers","subscription_url":"https://api.github.com/repos/4dn-dcic/fourfront/subscription","commits_url":"https://api.github.com/repos/4dn-dcic/fourfront/commits{/sha}","git_commits_url":"https://api.github.com/repos/4dn-dcic/fourfront/git/commits{/sha}","comments_url":"https://api.github.com/repos/4dn-dcic/fourfront/comments{/number}","issue_comment_url":"https://api.github.com/repos/4dn-dcic/fourfront/issues/comments{/number}","contents_url":"https://api.github.com/repos/4dn-dcic/fourfront/contents/{+path}","compare_url":"https://api.github.com/repos/4dn-dcic/fourfront/compare/{base}...{head}","merges_url":"https://api.github.com/repos/4dn-dcic/fourfront/merges","archive_url":"https://api.github.com/repos/4dn-dcic/fourfront/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/4dn-dcic/fourfront/downloads","issues_url":"https://api.github.com/repos/4dn-dcic/fourfront/issues{/number}","pulls_url":"https://api.github.com/repos/4dn-dcic/fourfront/pulls{/number}","milestones_url":"https://api.github.com/repos/4dn-dcic/fourfront/milestones{/number}","notifications_url":"https://api.github.com/repos/4dn-dcic/fourfront/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/4dn-dcic/fourfront/labels{/name}","releases_url":"https://api.github.com/repos/4dn-dcic/fourfront/releases{/id}","deployments_url":"https://api.github.com/repos/4dn-dcic/fourfront/deployments","created_at":"2016-05-09T18:19:56Z","updated_at":"2018-04-27T17:17:02Z","pushed_at":"2018-04-27T19:53:30Z","git_url":"git://github.com/4dn-dcic/fourfront.git","ssh_url":"git@github.com:4dn-dcic/fourfront.git","clone_url":"https://github.com/4dn-dcic/fourfront.git","svn_url":"https://github.com/4dn-dcic/fourfront","homepage":null,"size":196897,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":7,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/771"},"html":{"href":"https://github.com/4dn-dcic/fourfront/pull/771"},"issue":{"href":"https://api.github.com/repos/4dn-dcic/fourfront/issues/771"},"comments":{"href":"https://api.github.com/repos/4dn-dcic/fourfront/issues/771/comments"},"review_comments":{"href":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/771/comments"},"review_comment":{"href":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/4dn-dcic/fourfront/pulls/771/commits"},"statuses":{"href":"https://api.github.com/repos/4dn-dcic/fourfront/statuses/097e066f1a3b03920b0591fba29665e03b6df6ed"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"codacy-bot"}}