You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2023/06/24 16:51:11 UTC
[airavata-mft] branch master updated (2e48f51 -> 78b7aa0)
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
from 2e48f51 Build error on mac M1 Fixes #53
new 6fa77cf added a comment to test commit and push in Intellij
new ee1c556 Updated code to check for java run time
new 85e2e72 format fixes
new 08b6682 format fixes
new a205e4a format fixes
new e2edeaa format fixes
new 78b7aa0 PR changes
The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
python-cli/mft_cli/airavata_mft_cli/bootstrap.py | 49 +++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
[airavata-mft] 05/07: format fixes
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
commit a205e4ac9f5892b776759023d99433e86cda33de
Author: jfcsgthmbvnztjkcfcvjqjr <lo...@outlook.com>
AuthorDate: Fri Jun 23 23:01:07 2023 -0400
format fixes
---
python-cli/mft_cli/airavata_mft_cli/bootstrap.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
index 6bb96ac..d94b09d 100644
--- a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
+++ b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
@@ -29,7 +29,6 @@ from sys import platform
import shutil
import time
-
def download_and_unarchive(url, download_path, extract_dir = os.path.join(os.path.expanduser('~'), ".mft/")):
response = requests.get(url, stream=True)
file_size = int(response.headers['Content-Length'])
@@ -194,12 +193,11 @@ def update_mft():
def print_log():
log_file_path = os.path.join(os.path.expanduser('~'), ".mft", "Standalone-Service-0.01", "logs", "airavata.log")
- log_file = open(log_file_path, "r")
+ log_file = open(log_file_path,"r")
lines = follow_file(log_file)
for line in lines:
print(line)
-
def follow_file(file):
#file.seek(0, os.SEEK_END)
@@ -211,3 +209,4 @@ def follow_file(file):
yield line
+
[airavata-mft] 02/07: Updated code to check for java run time
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
commit ee1c556fd3430844b19ba37ad027e9f6db9d6dcc
Author: jfcsgthmbvnztjkcfcvjqjr <lo...@outlook.com>
AuthorDate: Fri Jun 23 22:25:00 2023 -0400
Updated code to check for java run time
---
python-cli/mft_cli/airavata_mft_cli/bootstrap.py | 286 +++++++++++++----------
python-cli/mft_cli/venv/pyvenv.cfg | 3 +
2 files changed, 165 insertions(+), 124 deletions(-)
diff --git a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
index da704ba..03777f8 100644
--- a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
+++ b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
@@ -20,6 +20,8 @@ import typer
import requests
import os
import zipfile
+from subprocess import check_output
+from subprocess import STDOUT
from subprocess import call
from subprocess import Popen
from pathlib import Path
@@ -27,152 +29,188 @@ from sys import platform
import shutil
import time
-def download_and_unarchive(url, download_path, extract_dir = os.path.join(os.path.expanduser('~'), ".mft/")):
- response = requests.get(url, stream=True)
- file_size = int(response.headers['Content-Length'])
- with typer.progressbar(length=file_size) as progress:
- with open(download_path, "wb") as handle:
- for data in response.iter_content(chunk_size=8192 * 2):
- progress.update(len(data))
- handle.write(data)
+def download_and_unarchive(url, download_path, extract_dir=os.path.join(os.path.expanduser('~'), ".mft/")):
+ response = requests.get(url, stream=True)
+ file_size = int(response.headers['Content-Length'])
+ with typer.progressbar(length=file_size) as progress:
+ with open(download_path, "wb") as handle:
+ for data in response.iter_content(chunk_size=8192 * 2):
+ progress.update(len(data))
+ handle.write(data)
- print("Un archiving ....")
- with zipfile.ZipFile(download_path,"r") as zip_ref:
- zip_ref.extractall(extract_dir)
+ print("Un archiving ....")
+ with zipfile.ZipFile(download_path, "r") as zip_ref:
+ zip_ref.extractall(extract_dir)
+
+ os.remove(download_path)
- os.remove(download_path)
def restart_service(bin_path, daemon_script_name):
- current_dir = os.getcwd()
- try:
- os.chdir(bin_path)
- os.chmod(daemon_script_name, 0o744)
- rc = call(["./" + daemon_script_name, "stop"])
- rc = call(["./" + daemon_script_name, "start"])
- finally:
- os.chdir(current_dir)
+ current_dir = os.getcwd()
+ try:
+ os.chdir(bin_path)
+ os.chmod(daemon_script_name, 0o744)
+ rc = call(["./" + daemon_script_name, "stop"])
+ rc = call(["./" + daemon_script_name, "start"])
+ finally:
+ os.chdir(current_dir)
+
def stop_service(bin_path, daemon_script_name):
- current_dir = os.getcwd()
- try:
- os.chdir(bin_path)
- os.chmod(daemon_script_name, 0o744)
- rc = call(["./" + daemon_script_name, "stop"])
- finally:
- os.chdir(current_dir)
-
-
-"""
- Issue 96: https://github.com/apache/airavata-mft/issues/96
-"""
+ current_dir = os.getcwd()
+ try:
+ os.chdir(bin_path)
+ os.chmod(daemon_script_name, 0o744)
+ rc = call(["./" + daemon_script_name, "stop"])
+ finally:
+ os.chdir(current_dir)
+
+
+def check_java_version_method(required_version):
+ """
+ Issue 96: https://github.com/apache/airavata-mft/issues/96
+
+ References:
+ ---------
+ https://stackoverflow.com/questions/31807882/get-java-version-number-from-python
+ https://stackoverflow.com/questions/1332598/how-to-determine-whether-java-is-installed-on-a-system-through-python
+ """
+ if shutil.which("java"):
+ res = check_output(['java', '-version'], stderr=STDOUT).decode('utf-8')
+ system_version = ''
+ count = 0
+ for c in res:
+ if c == '"' or count == 1:
+ if (c == '.' or c == '"') and count == 1:
+ break
+ if count == 0:
+ count += 1
+ continue
+ system_version += c
+
+ system_version = int(system_version)
+ if system_version < required_version:
+ print("Airavata MFT requires Java version 11 or higher")
+ print("If you have more than one version of java please set java version 11 or higher to the path")
+ raise typer.Exit()
+ else:
+ print("Java is either not installed or path hasn't been set properly")
+ raise typer.Exit()
+
+
def start_mft():
- print("Setting up MFT Services")
-
- if platform == "linux" or platform == "linux2":
- consul_url = "https://releases.hashicorp.com/consul/1.7.1/consul_1.7.1_linux_amd64.zip"
- elif platform == "darwin":
- consul_url = "https://releases.hashicorp.com/consul/1.7.1/consul_1.7.1_darwin_amd64.zip"
- elif platform == "win32":
- print("Windows support is not avialable yet")
- raise typer.Exit()
- else:
- print("Un supported platform: " + platform)
- raise typer.Exit()
-
- mft_dir = os.path.join(os.path.expanduser('~'), ".mft")
- if not os.path.exists(mft_dir):
- os.makedirs(mft_dir)
-
- path = os.path.join(os.path.expanduser('~'), ".mft/consul")
- if not os.path.exists(path):
- print("Downloading Consul...")
- zip_path = os.path.join(os.path.expanduser('~'), ".mft/consul.zip")
- download_and_unarchive(consul_url, zip_path, os.path.join(os.path.expanduser('~'), ".mft/"))
-
- current_dir = os.getcwd()
- try:
- os.chdir(os.path.join(os.path.expanduser('~'), ".mft"))
- os.chmod("consul", 0o744)
-
- if os.path.exists("consul.pid"):
- pid = Path('consul.pid').read_text()
- call(["kill", "-9", pid])
-
- consul_process = Popen(['nohup', './consul', "agent", "-dev"],
- stdout=open('consul.log', 'w'),
- stderr=open('consul.err.log', 'a'),
- preexec_fn=os.setpgrp)
-
- print("Consul process id: " + str(consul_process.pid))
- with open("consul.pid", "w") as consul_pid:
- consul_pid.write(str(consul_process.pid))
- finally:
- os.chdir(current_dir)
-
- path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01")
- if not os.path.exists(path):
- url = "https://github.com/apache/airavata-mft/releases/download/v0.0.1/Standalone-Service-0.01-bin.zip"
- print("Downloading MFT Server...")
- zip_path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01-bin.zip")
- download_and_unarchive(url, zip_path)
-
- restart_service(path + "/bin", "standalone-service-daemon.sh")
-
- print("MFT Started")
+ print("Setting up MFT Services")
+
+ required_java_version = 11
+ if platform == "linux" or platform == "linux2":
+ consul_url = "https://releases.hashicorp.com/consul/1.7.1/consul_1.7.1_linux_amd64.zip"
+ check_java_version_method(required_java_version)
+ elif platform == "darwin":
+ consul_url = "https://releases.hashicorp.com/consul/1.7.1/consul_1.7.1_darwin_amd64.zip"
+ check_java_version_method(required_java_version)
+ elif platform == "win32":
+ print("Windows support is not available yet")
+ raise typer.Exit()
+ else:
+ print("Un supported platform: " + platform)
+ raise typer.Exit()
+
+
+ mft_dir = os.path.join(os.path.expanduser('~'), ".mft")
+ if not os.path.exists(mft_dir):
+ os.makedirs(mft_dir)
+
+ path = os.path.join(os.path.expanduser('~'), ".mft/consul")
+ if not os.path.exists(path):
+ print("Downloading Consul...")
+ zip_path = os.path.join(os.path.expanduser('~'), ".mft/consul.zip")
+ download_and_unarchive(consul_url, zip_path, os.path.join(os.path.expanduser('~'), ".mft/"))
+
+ current_dir = os.getcwd()
+ try:
+ os.chdir(os.path.join(os.path.expanduser('~'), ".mft"))
+ os.chmod("consul", 0o744)
+
+ if os.path.exists("consul.pid"):
+ pid = Path('consul.pid').read_text()
+ call(["kill", "-9", pid])
+
+ consul_process = Popen(['nohup', './consul', "agent", "-dev"],
+ stdout=open('consul.log', 'w'),
+ stderr=open('consul.err.log', 'a'),
+ preexec_fn=os.setpgrp)
+
+ print("Consul process id: " + str(consul_process.pid))
+ with open("consul.pid", "w") as consul_pid:
+ consul_pid.write(str(consul_process.pid))
+ finally:
+ os.chdir(current_dir)
+
+ path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01")
+ if not os.path.exists(path):
+ url = "https://github.com/apache/airavata-mft/releases/download/v0.0.1/Standalone-Service-0.01-bin.zip"
+ print("Downloading MFT Server...")
+ zip_path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01-bin.zip")
+ download_and_unarchive(url, zip_path)
+
+ restart_service(path + "/bin", "standalone-service-daemon.sh")
+
+ print("MFT Started")
def stop_mft():
- print("Stopping MFT Services")
+ print("Stopping MFT Services")
- path = os.path.join(os.path.expanduser('~'), ".mft/consul")
- if os.path.exists(path):
- current_dir = os.getcwd()
- try:
- os.chdir(os.path.join(os.path.expanduser('~'), ".mft"))
- os.chmod("consul", 0o744)
+ path = os.path.join(os.path.expanduser('~'), ".mft/consul")
+ if os.path.exists(path):
+ current_dir = os.getcwd()
+ try:
+ os.chdir(os.path.join(os.path.expanduser('~'), ".mft"))
+ os.chmod("consul", 0o744)
- if os.path.exists("consul.pid"):
- pid = Path('consul.pid').read_text()
- call(["kill", "-9", pid])
- finally:
- os.chdir(current_dir)
+ if os.path.exists("consul.pid"):
+ pid = Path('consul.pid').read_text()
+ call(["kill", "-9", pid])
+ finally:
+ os.chdir(current_dir)
- path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01")
- if os.path.exists(path):
- stop_service(path + "/bin", "standalone-service-daemon.sh")
+ path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01")
+ if os.path.exists(path):
+ stop_service(path + "/bin", "standalone-service-daemon.sh")
+
+ print("MFT Stopped....")
- print("MFT Stopped....")
def update_mft():
- stop_mft()
+ stop_mft()
- mft_dir = os.path.join(os.path.expanduser('~'), ".mft")
- if os.path.exists(mft_dir):
- print("Removing .mft directory")
- shutil.rmtree(mft_dir)
+ mft_dir = os.path.join(os.path.expanduser('~'), ".mft")
+ if os.path.exists(mft_dir):
+ print("Removing .mft directory")
+ shutil.rmtree(mft_dir)
- database = os.path.join(os.path.expanduser('~'), "mft_db.mv.db")
- if os.path.exists(database):
- os.remove(database)
- start_mft()
+ database = os.path.join(os.path.expanduser('~'), "mft_db.mv.db")
+ if os.path.exists(database):
+ os.remove(database)
+ start_mft()
-def print_log():
- log_file_path = os.path.join(os.path.expanduser('~'), ".mft", "Standalone-Service-0.01", "logs", "airavata.log")
- log_file = open(log_file_path,"r")
- lines = follow_file(log_file)
- for line in lines:
- print(line)
-def follow_file(file):
- #file.seek(0, os.SEEK_END)
+def print_log():
+ log_file_path = os.path.join(os.path.expanduser('~'), ".mft", "Standalone-Service-0.01", "logs", "airavata.log")
+ log_file = open(log_file_path, "r")
+ lines = follow_file(log_file)
+ for line in lines:
+ print(line)
- while True:
- line = file.readline()
- if not line:
- time.sleep(0.1)
- continue
- yield line
+def follow_file(file):
+ # file.seek(0, os.SEEK_END)
+ while True:
+ line = file.readline()
+ if not line:
+ time.sleep(0.1)
+ continue
+ yield line
diff --git a/python-cli/mft_cli/venv/pyvenv.cfg b/python-cli/mft_cli/venv/pyvenv.cfg
new file mode 100644
index 0000000..740014e
--- /dev/null
+++ b/python-cli/mft_cli/venv/pyvenv.cfg
@@ -0,0 +1,3 @@
+home = /Library/Frameworks/Python.framework/Versions/3.10/bin
+include-system-site-packages = false
+version = 3.10.11
[airavata-mft] 03/07: format fixes
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
commit 85e2e7294491e76785405ef403c8c4b17d7a00d4
Author: jfcsgthmbvnztjkcfcvjqjr <lo...@outlook.com>
AuthorDate: Fri Jun 23 22:48:42 2023 -0400
format fixes
---
python-cli/mft_cli/airavata_mft_cli/bootstrap.py | 297 +++++++++++------------
1 file changed, 148 insertions(+), 149 deletions(-)
diff --git a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
index 03777f8..b9884bd 100644
--- a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
+++ b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
@@ -31,186 +31,185 @@ import time
def download_and_unarchive(url, download_path, extract_dir=os.path.join(os.path.expanduser('~'), ".mft/")):
- response = requests.get(url, stream=True)
- file_size = int(response.headers['Content-Length'])
- with typer.progressbar(length=file_size) as progress:
- with open(download_path, "wb") as handle:
- for data in response.iter_content(chunk_size=8192 * 2):
- progress.update(len(data))
- handle.write(data)
+ response = requests.get(url, stream=True)
+ file_size = int(response.headers['Content-Length'])
+ with typer.progressbar(length=file_size) as progress:
+ with open(download_path, "wb") as handle:
+ for data in response.iter_content(chunk_size=8192 * 2):
+ progress.update(len(data))
+ handle.write(data)
- print("Un archiving ....")
- with zipfile.ZipFile(download_path, "r") as zip_ref:
- zip_ref.extractall(extract_dir)
+ print("Un archiving ....")
+ with zipfile.ZipFile(download_path, "r") as zip_ref:
+ zip_ref.extractall(extract_dir)
- os.remove(download_path)
+ os.remove(download_path)
def restart_service(bin_path, daemon_script_name):
- current_dir = os.getcwd()
- try:
- os.chdir(bin_path)
- os.chmod(daemon_script_name, 0o744)
- rc = call(["./" + daemon_script_name, "stop"])
- rc = call(["./" + daemon_script_name, "start"])
- finally:
- os.chdir(current_dir)
+ current_dir = os.getcwd()
+ try:
+ os.chdir(bin_path)
+ os.chmod(daemon_script_name, 0o744)
+ rc = call(["./" + daemon_script_name, "stop"])
+ rc = call(["./" + daemon_script_name, "start"])
+ finally:
+ os.chdir(current_dir)
def stop_service(bin_path, daemon_script_name):
- current_dir = os.getcwd()
- try:
- os.chdir(bin_path)
- os.chmod(daemon_script_name, 0o744)
- rc = call(["./" + daemon_script_name, "stop"])
- finally:
- os.chdir(current_dir)
+ current_dir = os.getcwd()
+ try:
+ os.chdir(bin_path)
+ os.chmod(daemon_script_name, 0o744)
+ rc = call(["./" + daemon_script_name, "stop"])
+ finally:
+ os.chdir(current_dir)
def check_java_version_method(required_version):
- """
- Issue 96: https://github.com/apache/airavata-mft/issues/96
-
- References:
- ---------
- https://stackoverflow.com/questions/31807882/get-java-version-number-from-python
- https://stackoverflow.com/questions/1332598/how-to-determine-whether-java-is-installed-on-a-system-through-python
- """
- if shutil.which("java"):
- res = check_output(['java', '-version'], stderr=STDOUT).decode('utf-8')
- system_version = ''
- count = 0
- for c in res:
- if c == '"' or count == 1:
- if (c == '.' or c == '"') and count == 1:
- break
- if count == 0:
- count += 1
- continue
- system_version += c
-
- system_version = int(system_version)
- if system_version < required_version:
- print("Airavata MFT requires Java version 11 or higher")
- print("If you have more than one version of java please set java version 11 or higher to the path")
- raise typer.Exit()
- else:
- print("Java is either not installed or path hasn't been set properly")
- raise typer.Exit()
+ """
+ Issue 96: https://github.com/apache/airavata-mft/issues/96
+
+ References:
+ ---------
+ https://stackoverflow.com/questions/31807882/get-java-version-number-from-python
+ https://stackoverflow.com/questions/1332598/how-to-determine-whether-java-is-installed-on-a-system-through-python
+ """
+ if shutil.which("java"):
+ res = check_output(['java', '-version'], stderr=STDOUT).decode('utf-8')
+ system_version = ''
+ count = 0
+ for c in res:
+ if c == '"' or count == 1:
+ if (c == '.' or c == '"') and count == 1:
+ break
+ if count == 0:
+ count += 1
+ continue
+ system_version += c
+
+ system_version = int(system_version)
+ if system_version < required_version:
+ print("Airavata MFT requires Java version 11 or higher")
+ print("If you have more than one version of java please set java version 11 or higher to the path")
+ raise typer.Exit()
+ else:
+ print("Java is either not installed or path hasn't been set properly")
+ raise typer.Exit()
def start_mft():
- print("Setting up MFT Services")
-
- required_java_version = 11
- if platform == "linux" or platform == "linux2":
- consul_url = "https://releases.hashicorp.com/consul/1.7.1/consul_1.7.1_linux_amd64.zip"
- check_java_version_method(required_java_version)
- elif platform == "darwin":
- consul_url = "https://releases.hashicorp.com/consul/1.7.1/consul_1.7.1_darwin_amd64.zip"
- check_java_version_method(required_java_version)
- elif platform == "win32":
- print("Windows support is not available yet")
- raise typer.Exit()
- else:
- print("Un supported platform: " + platform)
- raise typer.Exit()
-
-
- mft_dir = os.path.join(os.path.expanduser('~'), ".mft")
- if not os.path.exists(mft_dir):
- os.makedirs(mft_dir)
-
- path = os.path.join(os.path.expanduser('~'), ".mft/consul")
- if not os.path.exists(path):
- print("Downloading Consul...")
- zip_path = os.path.join(os.path.expanduser('~'), ".mft/consul.zip")
- download_and_unarchive(consul_url, zip_path, os.path.join(os.path.expanduser('~'), ".mft/"))
-
- current_dir = os.getcwd()
- try:
- os.chdir(os.path.join(os.path.expanduser('~'), ".mft"))
- os.chmod("consul", 0o744)
-
- if os.path.exists("consul.pid"):
- pid = Path('consul.pid').read_text()
- call(["kill", "-9", pid])
-
- consul_process = Popen(['nohup', './consul', "agent", "-dev"],
- stdout=open('consul.log', 'w'),
- stderr=open('consul.err.log', 'a'),
- preexec_fn=os.setpgrp)
-
- print("Consul process id: " + str(consul_process.pid))
- with open("consul.pid", "w") as consul_pid:
- consul_pid.write(str(consul_process.pid))
- finally:
- os.chdir(current_dir)
-
- path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01")
- if not os.path.exists(path):
- url = "https://github.com/apache/airavata-mft/releases/download/v0.0.1/Standalone-Service-0.01-bin.zip"
- print("Downloading MFT Server...")
- zip_path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01-bin.zip")
- download_and_unarchive(url, zip_path)
-
- restart_service(path + "/bin", "standalone-service-daemon.sh")
-
- print("MFT Started")
+ print("Setting up MFT Services")
+
+ required_java_version = 11
+ if platform == "linux" or platform == "linux2":
+ consul_url = "https://releases.hashicorp.com/consul/1.7.1/consul_1.7.1_linux_amd64.zip"
+ check_java_version_method(required_java_version)
+ elif platform == "darwin":
+ consul_url = "https://releases.hashicorp.com/consul/1.7.1/consul_1.7.1_darwin_amd64.zip"
+ check_java_version_method(required_java_version)
+ elif platform == "win32":
+ print("Windows support is not available yet")
+ raise typer.Exit()
+ else:
+ print("Un supported platform: " + platform)
+ raise typer.Exit()
+
+ mft_dir = os.path.join(os.path.expanduser('~'), ".mft")
+ if not os.path.exists(mft_dir):
+ os.makedirs(mft_dir)
+
+ path = os.path.join(os.path.expanduser('~'), ".mft/consul")
+ if not os.path.exists(path):
+ print("Downloading Consul...")
+ zip_path = os.path.join(os.path.expanduser('~'), ".mft/consul.zip")
+ download_and_unarchive(consul_url, zip_path, os.path.join(os.path.expanduser('~'), ".mft/"))
+
+ current_dir = os.getcwd()
+ try:
+ os.chdir(os.path.join(os.path.expanduser('~'), ".mft"))
+ os.chmod("consul", 0o744)
+
+ if os.path.exists("consul.pid"):
+ pid = Path('consul.pid').read_text()
+ call(["kill", "-9", pid])
+
+ consul_process = Popen(['nohup', './consul', "agent", "-dev"],
+ stdout=open('consul.log', 'w'),
+ stderr=open('consul.err.log', 'a'),
+ preexec_fn=os.setpgrp)
+
+ print("Consul process id: " + str(consul_process.pid))
+ with open("consul.pid", "w") as consul_pid:
+ consul_pid.write(str(consul_process.pid))
+ finally:
+ os.chdir(current_dir)
+
+ path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01")
+ if not os.path.exists(path):
+ url = "https://github.com/apache/airavata-mft/releases/download/v0.0.1/Standalone-Service-0.01-bin.zip"
+ print("Downloading MFT Server...")
+ zip_path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01-bin.zip")
+ download_and_unarchive(url, zip_path)
+
+ restart_service(path + "/bin", "standalone-service-daemon.sh")
+
+ print("MFT Started")
def stop_mft():
- print("Stopping MFT Services")
+ print("Stopping MFT Services")
- path = os.path.join(os.path.expanduser('~'), ".mft/consul")
- if os.path.exists(path):
- current_dir = os.getcwd()
- try:
- os.chdir(os.path.join(os.path.expanduser('~'), ".mft"))
- os.chmod("consul", 0o744)
+ path = os.path.join(os.path.expanduser('~'), ".mft/consul")
+ if os.path.exists(path):
+ current_dir = os.getcwd()
+ try:
+ os.chdir(os.path.join(os.path.expanduser('~'), ".mft"))
+ os.chmod("consul", 0o744)
- if os.path.exists("consul.pid"):
- pid = Path('consul.pid').read_text()
- call(["kill", "-9", pid])
- finally:
- os.chdir(current_dir)
+ if os.path.exists("consul.pid"):
+ pid = Path('consul.pid').read_text()
+ call(["kill", "-9", pid])
+ finally:
+ os.chdir(current_dir)
- path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01")
- if os.path.exists(path):
- stop_service(path + "/bin", "standalone-service-daemon.sh")
+ path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01")
+ if os.path.exists(path):
+ stop_service(path + "/bin", "standalone-service-daemon.sh")
- print("MFT Stopped....")
+ print("MFT Stopped....")
def update_mft():
- stop_mft()
+ stop_mft()
- mft_dir = os.path.join(os.path.expanduser('~'), ".mft")
- if os.path.exists(mft_dir):
- print("Removing .mft directory")
- shutil.rmtree(mft_dir)
+ mft_dir = os.path.join(os.path.expanduser('~'), ".mft")
+ if os.path.exists(mft_dir):
+ print("Removing .mft directory")
+ shutil.rmtree(mft_dir)
- database = os.path.join(os.path.expanduser('~'), "mft_db.mv.db")
- if os.path.exists(database):
- os.remove(database)
- start_mft()
+ database = os.path.join(os.path.expanduser('~'), "mft_db.mv.db")
+ if os.path.exists(database):
+ os.remove(database)
+ start_mft()
def print_log():
- log_file_path = os.path.join(os.path.expanduser('~'), ".mft", "Standalone-Service-0.01", "logs", "airavata.log")
- log_file = open(log_file_path, "r")
- lines = follow_file(log_file)
- for line in lines:
- print(line)
+ log_file_path = os.path.join(os.path.expanduser('~'), ".mft", "Standalone-Service-0.01", "logs", "airavata.log")
+ log_file = open(log_file_path, "r")
+ lines = follow_file(log_file)
+ for line in lines:
+ print(line)
def follow_file(file):
- # file.seek(0, os.SEEK_END)
+ # file.seek(0, os.SEEK_END)
- while True:
- line = file.readline()
- if not line:
- time.sleep(0.1)
- continue
+ while True:
+ line = file.readline()
+ if not line:
+ time.sleep(0.1)
+ continue
- yield line
+ yield line
[airavata-mft] 01/07: added a comment to test commit and push in Intellij
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
commit 6fa77cfe662d01343568e3d4beb82ef50f76967a
Author: jfcsgthmbvnztjkcfcvjqjr <lo...@outlook.com>
AuthorDate: Wed Jun 21 13:54:25 2023 -0400
added a comment to test commit and push in Intellij
---
python-cli/mft_cli/airavata_mft_cli/bootstrap.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
index 9e78be6..da704ba 100644
--- a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
+++ b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
@@ -62,6 +62,10 @@ def stop_service(bin_path, daemon_script_name):
finally:
os.chdir(current_dir)
+
+"""
+ Issue 96: https://github.com/apache/airavata-mft/issues/96
+"""
def start_mft():
print("Setting up MFT Services")
[airavata-mft] 04/07: format fixes
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
commit 08b66828a236dd065b9f3014f0692132999c2c9e
Author: jfcsgthmbvnztjkcfcvjqjr <lo...@outlook.com>
AuthorDate: Fri Jun 23 22:57:30 2023 -0400
format fixes
---
python-cli/mft_cli/airavata_mft_cli/bootstrap.py | 26 +++++++++++-------------
python-cli/mft_cli/venv/pyvenv.cfg | 3 ---
2 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
index b9884bd..6bb96ac 100644
--- a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
+++ b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
@@ -30,7 +30,7 @@ import shutil
import time
-def download_and_unarchive(url, download_path, extract_dir=os.path.join(os.path.expanduser('~'), ".mft/")):
+def download_and_unarchive(url, download_path, extract_dir = os.path.join(os.path.expanduser('~'), ".mft/")):
response = requests.get(url, stream=True)
file_size = int(response.headers['Content-Length'])
with typer.progressbar(length=file_size) as progress:
@@ -40,14 +40,14 @@ def download_and_unarchive(url, download_path, extract_dir=os.path.join(os.path.
handle.write(data)
print("Un archiving ....")
- with zipfile.ZipFile(download_path, "r") as zip_ref:
+ with zipfile.ZipFile(download_path,"r") as zip_ref:
zip_ref.extractall(extract_dir)
os.remove(download_path)
def restart_service(bin_path, daemon_script_name):
- current_dir = os.getcwd()
+ current_dir = os.getcwd()
try:
os.chdir(bin_path)
os.chmod(daemon_script_name, 0o744)
@@ -56,9 +56,8 @@ def restart_service(bin_path, daemon_script_name):
finally:
os.chdir(current_dir)
-
def stop_service(bin_path, daemon_script_name):
- current_dir = os.getcwd()
+ current_dir = os.getcwd()
try:
os.chdir(bin_path)
os.chmod(daemon_script_name, 0o744)
@@ -126,7 +125,7 @@ def start_mft():
zip_path = os.path.join(os.path.expanduser('~'), ".mft/consul.zip")
download_and_unarchive(consul_url, zip_path, os.path.join(os.path.expanduser('~'), ".mft/"))
- current_dir = os.getcwd()
+ current_dir = os.getcwd()
try:
os.chdir(os.path.join(os.path.expanduser('~'), ".mft"))
os.chmod("consul", 0o744)
@@ -136,9 +135,9 @@ def start_mft():
call(["kill", "-9", pid])
consul_process = Popen(['nohup', './consul', "agent", "-dev"],
- stdout=open('consul.log', 'w'),
- stderr=open('consul.err.log', 'a'),
- preexec_fn=os.setpgrp)
+ stdout=open('consul.log', 'w'),
+ stderr=open('consul.err.log', 'a'),
+ preexec_fn=os.setpgrp)
print("Consul process id: " + str(consul_process.pid))
with open("consul.pid", "w") as consul_pid:
@@ -163,7 +162,7 @@ def stop_mft():
path = os.path.join(os.path.expanduser('~'), ".mft/consul")
if os.path.exists(path):
- current_dir = os.getcwd()
+ current_dir = os.getcwd()
try:
os.chdir(os.path.join(os.path.expanduser('~'), ".mft"))
os.chmod("consul", 0o744)
@@ -180,7 +179,6 @@ def stop_mft():
print("MFT Stopped....")
-
def update_mft():
stop_mft()
@@ -194,17 +192,16 @@ def update_mft():
os.remove(database)
start_mft()
-
def print_log():
log_file_path = os.path.join(os.path.expanduser('~'), ".mft", "Standalone-Service-0.01", "logs", "airavata.log")
- log_file = open(log_file_path, "r")
+ log_file = open(log_file_path, "r")
lines = follow_file(log_file)
for line in lines:
print(line)
def follow_file(file):
- # file.seek(0, os.SEEK_END)
+ #file.seek(0, os.SEEK_END)
while True:
line = file.readline()
@@ -213,3 +210,4 @@ def follow_file(file):
continue
yield line
+
diff --git a/python-cli/mft_cli/venv/pyvenv.cfg b/python-cli/mft_cli/venv/pyvenv.cfg
deleted file mode 100644
index 740014e..0000000
--- a/python-cli/mft_cli/venv/pyvenv.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-home = /Library/Frameworks/Python.framework/Versions/3.10/bin
-include-system-site-packages = false
-version = 3.10.11
[airavata-mft] 07/07: PR changes
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
commit 78b7aa09da64c11e34db28c512d3da123b3ea2bd
Author: jfcsgthmbvnztjkcfcvjqjr <lo...@outlook.com>
AuthorDate: Sat Jun 24 07:36:26 2023 -0400
PR changes
---
python-cli/mft_cli/airavata_mft_cli/bootstrap.py | 27 ++++++++++++++++--------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
index 0c0fbc8..a2d9085 100644
--- a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
+++ b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
@@ -65,7 +65,7 @@ def stop_service(bin_path, daemon_script_name):
os.chdir(current_dir)
-def check_java_version_method(required_version):
+def validate_java_availability(required_version):
"""
Issue 96: https://github.com/apache/airavata-mft/issues/96
@@ -73,10 +73,19 @@ def check_java_version_method(required_version):
---------
https://stackoverflow.com/questions/31807882/get-java-version-number-from-python
https://stackoverflow.com/questions/1332598/how-to-determine-whether-java-is-installed-on-a-system-through-python
+ https://stackoverflow.com/questions/74206258/how-are-oracle-jdk-versions-numbered
+ https://docs.python.org/3.8/library/subprocess.html#subprocess.check_output
+ https://stackoverflow.com/questions/2411288/java-versioning-and-terminology-1-6-vs-6-0-openjdk-vs-sun
"""
if shutil.which("java"):
res = check_output(['java', '-version'], stderr=STDOUT).decode('utf-8')
- system_version = ''
+ """
+ res will have the value similar to the following
+ openjdk version "17.0.5" 2022-10-18 LTS
+ OpenJDK Runtime Environment Corretto-17.0.5.8.1 (build 17.0.5+8-LTS)
+ OpenJDK 64-Bit Server VM Corretto-17.0.5.8.1 (build 17.0.5+8-LTS, mixed mode, sharing)
+ """
+ java_version = ''
count = 0
for c in res:
if c == '"' or count == 1:
@@ -85,12 +94,12 @@ def check_java_version_method(required_version):
if count == 0:
count += 1
continue
- system_version += c
+ java_version += c
- system_version = int(system_version)
- if system_version < required_version:
- print("Airavata MFT requires Java version 11 or higher")
- print("If you have more than one version of java please set java version 11 or higher to the path")
+ java_version = int(java_version)
+ if java_version < required_version:
+ print("Airavata MFT requires Java version " + required_version + " or higher")
+ print("If you have more than one version of java please set java version "+ required_version +" or higher to the path")
raise typer.Exit()
else:
print("Java is either not installed or path hasn't been set properly")
@@ -103,10 +112,10 @@ def start_mft():
required_java_version = 11
if platform == "linux" or platform == "linux2":
consul_url = "https://releases.hashicorp.com/consul/1.7.1/consul_1.7.1_linux_amd64.zip"
- check_java_version_method(required_java_version)
+ validate_java_availability(required_java_version)
elif platform == "darwin":
consul_url = "https://releases.hashicorp.com/consul/1.7.1/consul_1.7.1_darwin_amd64.zip"
- check_java_version_method(required_java_version)
+ validate_java_availability(required_java_version)
elif platform == "win32":
print("Windows support is not available yet")
raise typer.Exit()
[airavata-mft] 06/07: format fixes
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
commit e2edeaaa089907dae1c3343e9c706a09cd611264
Author: jfcsgthmbvnztjkcfcvjqjr <lo...@outlook.com>
AuthorDate: Fri Jun 23 23:03:19 2023 -0400
format fixes
---
python-cli/mft_cli/airavata_mft_cli/bootstrap.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
index d94b09d..0c0fbc8 100644
--- a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
+++ b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py
@@ -30,6 +30,7 @@ import shutil
import time
def download_and_unarchive(url, download_path, extract_dir = os.path.join(os.path.expanduser('~'), ".mft/")):
+
response = requests.get(url, stream=True)
file_size = int(response.headers['Content-Length'])
with typer.progressbar(length=file_size) as progress:
@@ -44,7 +45,6 @@ def download_and_unarchive(url, download_path, extract_dir = os.path.join(os.pat
os.remove(download_path)
-
def restart_service(bin_path, daemon_script_name):
current_dir = os.getcwd()
try: