Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert bash scripts to Python #7465

Merged
merged 156 commits into from
Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
6ac0724
initial
Aug 17, 2019
13c37f9
fix lint
Aug 18, 2019
9ae6f2e
fix
Aug 18, 2019
2eca67e
fix
Aug 18, 2019
c9b6f98
conver
Aug 19, 2019
7218092
fix
Aug 19, 2019
9250dcb
fix
Aug 19, 2019
9d33246
convert
Aug 19, 2019
41113da
fix
Aug 19, 2019
4fe2b2d
Merge branch 'develop' into convert_bash_1
Aug 20, 2019
406129e
Merge branch 'develop' into convert_bash_1
Aug 21, 2019
beb3c52
add
Aug 22, 2019
77e21d7
convert
Aug 22, 2019
c5e3c97
fix lint
Aug 22, 2019
a5eebeb
convert
Aug 22, 2019
f9a8586
convert
Aug 22, 2019
afb7068
Merge branch 'develop' into convert_bash_1
Aug 23, 2019
dc1845c
convert
Aug 23, 2019
eee27b9
convert
Aug 24, 2019
a6dc5bb
convert
Aug 24, 2019
e88fd13
address
Aug 24, 2019
c373919
fix path
Aug 24, 2019
06dc081
convert
Aug 24, 2019
6b57f85
Merge branch 'develop' into convert_bash_1
Aug 25, 2019
845a94c
remove files
Aug 25, 2019
4df7247
convert
Aug 25, 2019
d3a2464
fix comment
Aug 25, 2019
275d886
convert
Aug 25, 2019
3482864
convert
Aug 25, 2019
0ab00ec
fix
Aug 25, 2019
cbb09a7
address comments
Aug 25, 2019
d2ed087
convert
Aug 25, 2019
1ced71c
convert
Aug 25, 2019
60510ae
fix lint
Aug 25, 2019
f83f917
update circleci
Aug 25, 2019
fb26396
fix
Aug 25, 2019
d0a9f56
convert
Aug 25, 2019
df0c880
fix
Aug 25, 2019
af66d95
fix
Aug 25, 2019
48c8ce8
fix
Aug 25, 2019
fcbbbb0
fix
Aug 25, 2019
0af2fc4
Merge branch 'develop' into convert_bash_1
Aug 25, 2019
d3f80a3
sync with develop
Aug 25, 2019
740eb7a
fix
Aug 25, 2019
c6ae74b
fix conflicts
Aug 26, 2019
2834e82
use parse known args
Aug 26, 2019
8bbda96
remove user
Aug 26, 2019
cd84f0b
fix pip
Aug 27, 2019
2c03e24
try subprocess on pip install
Aug 27, 2019
cd4a824
fix
Aug 27, 2019
ae51254
fix
Aug 27, 2019
a7e21c5
fix
Aug 27, 2019
e9fd69d
fix
Aug 27, 2019
b26d7dc
fix
Aug 27, 2019
33a10ce
add node path
Aug 27, 2019
8ba23a5
fix
Aug 27, 2019
db7a003
fix lint
Aug 27, 2019
f521c7a
add args
Aug 27, 2019
b6d5878
fix lint
Aug 27, 2019
3086329
merge develo
Aug 27, 2019
b912d6d
add path
Aug 27, 2019
efabda0
address comments
Aug 27, 2019
899228a
address comments
Aug 27, 2019
6044c23
fix
Aug 27, 2019
c28656b
fix
Aug 27, 2019
2d62316
fix
Aug 27, 2019
1e7bcdb
fix
Aug 27, 2019
3a97331
fix frontend
Aug 28, 2019
cfad6b3
fix
Aug 28, 2019
11ae549
fix start
Aug 28, 2019
46eb948
fix lint
Aug 28, 2019
95b6ca9
clear cache
Aug 28, 2019
7130eb7
revert
Aug 28, 2019
13155a5
remove pylint
Aug 28, 2019
86647a8
remove pylint path
Aug 28, 2019
7c47253
add path
Aug 28, 2019
efc69b0
add pylint path
Aug 28, 2019
834bffa
fix
Aug 28, 2019
0186a8a
fix
Aug 28, 2019
326eda8
use vurtual env
Aug 28, 2019
4f4b3c2
fix
Aug 28, 2019
ad9fbae
fix
Aug 28, 2019
34efc74
add url in travis yaml
Aug 28, 2019
2d3d642
test
Aug 28, 2019
dcf6ec3
test
Aug 28, 2019
b532ba0
fix
Aug 28, 2019
f58f27a
test
Aug 28, 2019
93b7cf4
test
Aug 28, 2019
01970a5
test
Aug 28, 2019
eda2856
test
Aug 28, 2019
92d39d5
test
Aug 28, 2019
98b324b
test
Aug 28, 2019
4cc089c
test
Aug 28, 2019
2f2871c
tes
Aug 28, 2019
14d2659
fi
Aug 28, 2019
862490c
fix
Aug 28, 2019
1ec120f
test
Aug 28, 2019
9386c0c
fix conflicts
Aug 29, 2019
11d891d
fix
Aug 29, 2019
07eaf2b
Merge branch 'develop' into convert_bash_1
Aug 30, 2019
ce7d114
fix
Aug 30, 2019
6f04c1b
fix test
Aug 30, 2019
767d97e
fix
Aug 30, 2019
82804cb
fix conflicts
Aug 31, 2019
8e43243
fix
Aug 31, 2019
fabf517
address comments
Aug 31, 2019
8b7bb5a
fix
Aug 31, 2019
057f2e6
fix node
Aug 31, 2019
8003bfe
fix
Aug 31, 2019
25b64ad
remove vagrant
Aug 31, 2019
0492abe
fix
Aug 31, 2019
fd168ab
address comments
Aug 31, 2019
77ddcbc
fix conflicts
Aug 31, 2019
d89c3b0
fix lint
Aug 31, 2019
251669a
fix
Aug 31, 2019
b07b0d9
fix
Aug 31, 2019
03e56b7
address comments
Aug 31, 2019
770cd4f
fix
Aug 31, 2019
fafbde2
fix
Sep 1, 2019
9ec9238
fix
Sep 1, 2019
33f38a7
fix
Sep 1, 2019
35cfe60
fix
Sep 1, 2019
af6ad16
merge develop
Sep 2, 2019
55a1a99
address comments
Sep 2, 2019
c604eae
fix
Sep 2, 2019
90b50d8
fix
Sep 2, 2019
5bdc8b1
fix
Sep 2, 2019
891d088
only one backend_tests.py
Sep 2, 2019
a6e6b28
address comments
Sep 2, 2019
a42a17c
Merge branch 'develop' into convert_bash_1
Sep 2, 2019
28eaabe
fix
Sep 2, 2019
6e9b993
fix
Sep 2, 2019
7bf028d
fix
Sep 2, 2019
f0ebb60
fix
Sep 2, 2019
8fe8d20
fix errors
Sep 2, 2019
b73afbf
address comments
Sep 2, 2019
1b4638b
fix
Sep 2, 2019
64fc6c5
use None and args
Sep 2, 2019
320b65e
fix permission
Sep 2, 2019
127cead
fix
Sep 2, 2019
595be3c
fix conflicts
Sep 2, 2019
6939582
address comments
Sep 2, 2019
80a9599
fix e2e
Sep 3, 2019
5ac03b0
address comments
Sep 3, 2019
9a84e6f
fix
Sep 3, 2019
770c6f3
fix
Sep 3, 2019
d713208
skip e2e
Sep 3, 2019
c3006d2
remove yaml
Sep 3, 2019
2459c84
fix lint
Sep 3, 2019
89f61e6
use single quotes
Sep 4, 2019
07814eb
fix conflicts
Sep 7, 2019
89afe82
fix conflicts
Sep 7, 2019
6967564
test
Sep 7, 2019
6ba9902
fix linr
Sep 7, 2019
943759b
add tests
Sep 8, 2019
911d84a
use triple strings
Sep 8, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
Rishav Chakraborty committed Aug 31, 2019
commit 8b7bb5a3acb478eac2db36d5ed84bebbcd3f8a6f
17 changes: 9 additions & 8 deletions scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ def recursive_chmod(path, mode):
os.chmod(os.path.join(root, filename), mode)


def print_string_after_two_new_lines(strings):
"""Prints each string after two new lines.
def print_each_string_after_two_new_lines(strings):
"""Prints the given strings, separating adjacent strings with two newlines.

Args:
strings: list(str). The strings to print.
Expand All @@ -268,19 +268,20 @@ def print_string_after_two_new_lines(strings):
python_utils.PRINT('%s\n' % string)


def install_npm_library(library, version, path):
def install_npm_library(library_name, version, path):
"""Installs the npm library after ensuring its not already installed.

Args:
library: str. The library name.
library_name: str. The library name.
version: str. The library version.
path: str. The installation path for the library.
"""
python_utils.PRINT(
'Checking whether %s is installed in %s' % (library, path))
if not os.path.exists(os.path.join(NODE_MODULES_PATH, library)):
python_utils.PRINT('Installing %s' % library)
subprocess.call([NPM_PATH, 'install', '%s@%s' % (library, version)])
'Checking whether %s is installed in %s' % (library_name, path))
if not os.path.exists(os.path.join(NODE_MODULES_PATH, library_name)):
python_utils.PRINT('Installing %s' % library_name)
subprocess.call([
NPM_PATH, 'install', '%s@%s' % (library_name, version)])


class CD(python_utils.OBJECT):
Expand Down
2 changes: 1 addition & 1 deletion scripts/create_expression_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""It produces the expression parser."""
"""This script produces the expression parser."""
from __future__ import absolute_import # pylint: disable=import-only-modules

import fileinput
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_third_party_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def pip_install(package, version, install_path):
python_utils.PRINT('Checking if pip is installed on the local machine')
import pip
except ImportError:
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'Pip is required to install Oppia dependencies, but pip wasn\'t '
'found',
'on your local machine.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused about why you want to separate the previous two strings by two newlines...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in the same line

Expand Down
2 changes: 1 addition & 1 deletion scripts/run_backend_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""It runs all the (Python) backend tests, in parallel."""
"""This script runs all the (Python) backend tests, in parallel."""
from __future__ import absolute_import # pylint: disable=import-only-modules

import argparse
Expand Down
6 changes: 3 additions & 3 deletions scripts/run_e2e_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def cleanup():
time.sleep(1)

if os.path.isdir('../protractor-screenshots'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split paths and don't include dir separators in the strings. Ditto below and elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'Note: If ADD_SCREENSHOT_REPORTER is set to true in',
'core/tests/protractor.conf.js, you can view screenshots',
'of the failed tests in ../protractor-screenshots/'])
Expand All @@ -98,14 +98,14 @@ def main(argv=None):
parsed_args.skip_install, parsed_args.run_minified_tests)

if common.is_port_open(8181):
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'There is already a server running on localhost:8181.',
'Please terminate it before running the end-to-end tests.',
'Exiting.'])
sys.exit(1)

if common.is_port_open(9001):
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'There is already a server running on localhost:9001.',
'Please terminate it before running the end-to-end tests.',
'Exiting.'])
Expand Down
4 changes: 2 additions & 2 deletions scripts/run_frontend_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""It runs unit tests for frontend JavaScript code (using Karma)."""
"""This script runs unit tests for frontend JavaScript code (using Karma)."""
from __future__ import absolute_import # pylint: disable=import-only-modules

import argparse
Expand Down Expand Up @@ -50,7 +50,7 @@ def main(argv=None):
parsed_args, _ = _PARSER.parse_known_args(args=argv)
install_third_party_libs.maybe_install_dependencies(
parsed_args.skip_install, parsed_args.run_minified_tests)
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'View interactive frontend test coverage reports by navigating to',
'../karma_coverage_reports',
'on your filesystem.',
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_performance_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def main(argv=None):
parsed_args.skip_install, parsed_args.run_minified_tests)

if common.is_port_open(8181):
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'There is already a server running on localhost:8181',
'Please terminate it before running the performance tests.',
'Exiting.'])
Expand Down
4 changes: 2 additions & 2 deletions scripts/run_presubmit_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""It runs the following tests in all cases.
"""This script runs the following tests in all cases.
- Javascript and Python Linting
brianrodri marked this conversation as resolved.
Show resolved Hide resolved
- Backend Python tests

Expand Down Expand Up @@ -78,7 +78,7 @@ def main(argv=None):
python_utils.PRINT('Frontend tests passed.')
else:
# If files in common.FRONTEND_DIR were not changed, skip the tests.
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'No frontend files were changed.',
'Skipped frontend tests'])

Expand Down
2 changes: 1 addition & 1 deletion scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""It runs all the tests, in this order:
"""This script runs all the tests, in this order:
- Frontend Karma unit tests
- Backend Python tests
- End-to-end Protractor tests
Expand Down
4 changes: 2 additions & 2 deletions scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_python_version():
# path.
os_info = os.uname()
if os_info[0] != 'Darwin' and os_info[0] != 'Linux':
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'It looks like you are using Windows. If you have Python '
'installed,',
'make sure it is in your PATH and that PYTHONPATH is set.',
Expand Down Expand Up @@ -104,7 +104,7 @@ def main():
if os_info[0] != 'Darwin' and os_info[0] != 'Linux':
# Node is a requirement for all installation scripts. Here, we check if
# the OS supports node.js installation; if not, we exit with an error.
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'WARNING: Unsupported OS for installation of node.js.',
'If you are running this script on Windows, see the instructions',
'here regarding installation of node.js:',
Expand Down
12 changes: 6 additions & 6 deletions scripts/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

def cleanup():
"""Function for waiting for the servers to go down."""
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'INFORMATION',
'Cleaning up the servers.'])
while common.is_port_open(8181):
Expand All @@ -82,7 +82,7 @@ def main(argv=None):

# Check that there isn't a server already running.
if common.is_port_open(8181):
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'WARNING',
'Could not start new server. There is already an existing server',
'running at port 8181.'])
Expand Down Expand Up @@ -153,13 +153,13 @@ def main(argv=None):
if list(filter(
detect_virtualbox_pattern.match,
os.listdir('/dev/disk/by-id/'))):
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'INFORMATION',
'Setting up a local development server. You can access this '
'server',
'by navigating to localhost:8181 in a browser window.'])
else:
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'INFORMATION',
'Setting up a local development server at localhost:8181. '
'Opening a',
Expand All @@ -168,7 +168,7 @@ def main(argv=None):
background_processes.append(
subprocess.Popen(['xdg-open', 'http://localhost:8181/']))
elif os_info[0] == 'Darwin' and not parsed_args.no_browser:
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'INFORMATION',
'Setting up a local development server at localhost:8181. '
'Opening a',
Expand All @@ -177,7 +177,7 @@ def main(argv=None):
background_processes.append(
subprocess.Popen(['open', 'http://localhost:8181/']))
else:
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'INFORMATION',
'Setting up a local development server. You can access this server',
'by navigating to localhost:8181 in a browser window.'])
Expand Down
2 changes: 1 addition & 1 deletion scripts/vagrant_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def main(argv=None):
sys.exit(0)

if os.path.isfile(vagrant_lock_file):
common.print_string_after_two_new_lines([
common.print_each_string_after_two_new_lines([
'Another setup instance is already running',
'Please wait for that instance to complete or terminate it',
'If you ran $0 twice on purpose, you can override this with ',
Expand Down