Skip to content

Commit

Permalink
Merge pull request #420 from atlas-bi/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherpickering authored Aug 3, 2023
2 parents dc24871 + bb335eb commit de79a5e
Show file tree
Hide file tree
Showing 317 changed files with 1,914 additions and 1,271 deletions.
35 changes: 35 additions & 0 deletions migrations/versions/6b8978d637c5_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""empty message
Revision ID: 6b8978d637c5
Revises: 0fe33867bdbf
Create Date: 2023-08-03 12:53:03.650434
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '6b8978d637c5'
down_revision = '0fe33867bdbf'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('connection_sftp', schema=None) as batch_op:
batch_op.add_column(sa.Column('key_password', sa.Text(), nullable=True))

# ### end Alembic commands ###

# move passwords on connections that have a key into the key_password field and clear the
# password field.
op.execute('update connection_sftp set key_password=password where key is not null')
op.execute('update connection_sftp set password=null where key is not null and key_password=password')

def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('connection_sftp', schema=None) as batch_op:
batch_op.drop_column('key_password')

# ### end Alembic commands ###
28 changes: 16 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"gulp-purgecss": "5.0.0",
"gulp-rename": "2.0.0",
"gulp-uglify": "3.0.2",
"prettier": "2.8.8",
"prettier": "3.0.0",
"semantic-release": "21.0.5"
},
"homepage": "https://atlas-hub.atlas.bi",
Expand Down Expand Up @@ -80,5 +80,5 @@
"test:lint": "poetry run tox -e lint",
"test:prettier": "prettier --check --config .prettierrc \"web/**/*.{ts,css,less,scss,js,json,md,yaml,html}\""
},
"version": "2.10.3-alpha.1"
"version": "2.10.5"
}
175 changes: 114 additions & 61 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ cryptography = "^41.0.0"
flask-assets = {git = "https://github.com/christopherpickering/flask-assets.git"}
flask-redis = "^0.4.0"
flask-session2 = "^1.2.0"
gevent = "^22.0.0"
gevent = "^23.0.0"
gunicorn = "^20.1.0"
is-safe-url = "^1.0"
paramiko = "^3.0.0"
Expand Down
1 change: 1 addition & 0 deletions runner/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class ConnectionSftp(db.Model):
username = db.Column(db.String(120), nullable=True)
key = db.Column(db.String(8000), nullable=True)
password = db.Column(db.Text, nullable=True)
key_password = db.Column(db.Text, nullable=True)
task = db.relationship(
"Task",
backref="destination_sftp_conn",
Expand Down
1 change: 1 addition & 0 deletions runner/scripts/em_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def __init__(
success=0,
date=date,
logs=logs,
org=app.config["ORG_NAME"],
),
short_message=task.email_error_message
or f"Atlas Hub task {task} failed.",
Expand Down
4 changes: 2 additions & 2 deletions runner/scripts/em_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def run(self) -> Optional[List[Path]]:

# if output is not a file list, then swallow it.

if isinstance(self.output, List):
return self.output
if isinstance(eval(self.output), List):
return [Path(x) for x in eval(self.output)]
return None

def __build_env(self) -> None:
Expand Down
34 changes: 24 additions & 10 deletions runner/scripts/em_sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def connection_key(connection: ConnectionSftp) -> Optional[paramiko.pkey.PKey]:

key = paramiko.RSAKey.from_private_key_file(
key_file.name,
password=em_decrypt(connection.password, app.config["PASS_KEY"])
if connection.password
password=em_decrypt(connection.key_password, app.config["PASS_KEY"])
if connection.key_password
else None,
)

Expand All @@ -54,6 +54,7 @@ def connection_json(connection: ConnectionSftp) -> Dict:
"port": connection.port or 22,
"key": em_decrypt(connection.key, app.config["PASS_KEY"]),
"password": em_decrypt(connection.password, app.config["PASS_KEY"]),
"key_password": em_decrypt(connection.key_password, app.config["PASS_KEY"]),
"username": str(connection.username),
}

Expand All @@ -74,15 +75,28 @@ def connect(connection: ConnectionSftp) -> Tuple[Transport, SFTPClient]:

key = connection_key(connection)

transport.connect(
username=str(connection.username),
password=(
if key and connection.password and connection.username:
transport.start_client(event=None, timeout=15)
transport.get_remote_server_key()
transport.auth_publickey(connection.username, key, event=None)
transport.auth_password(
connection.username,
em_decrypt(connection.password, app.config["PASS_KEY"])
if key is None
else ""
),
pkey=key,
)
if connection.password
else "",
event=None,
)

else:
transport.connect(
username=str(connection.username),
password=(
em_decrypt(connection.password, app.config["PASS_KEY"])
if connection.password
else ""
),
pkey=key,
)

conn = paramiko.SFTPClient.from_transport(transport)
if conn is None:
Expand Down
3 changes: 2 additions & 1 deletion runner/scripts/task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def __send_email(self) -> None:
.all()
)

date = str(datetime.datetime.now())
date = datetime.datetime.now()

# pylint: disable=broad-except
try:
Expand Down Expand Up @@ -820,6 +820,7 @@ def __send_email(self) -> None:
logs=logs,
output=output,
host=app.config["WEB_HOST"],
org=app.config["ORG_NAME"],
),
short_message=self.task.email_completion_message
or f"Atlas Hub job {self.task} completed successfully.",
Expand Down
6 changes: 3 additions & 3 deletions runner/templates/email/email.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@
font-size: 35px;
margin:0;
font-weight:lighter">Atlas / Hub</h2>
<div style="color: #6c7378;font-size: 15px;">&#169; 2020 Riverside Healthcare</div>
<div style="color: #6c7378;font-size: 15px;">&#169;{{ date.year }} {{ org }}</div>
</div>
<!-- task title -->
<h3>
Project:
<a style="color: #6c7378;
text-decoration: none"
href="{{ host }}/project/{{ task.projectId }}">{{ task.project.name }}</a>
href="{{ host }}/project/{{ task.project.id }}">{{ task.project.name }}</a>
/ Task:
<a style="color: #6c7378;
text-decoration: none"
href="{{ host }}/task/{{ task.id }}">{{ task.name }}</a>
/ Run:
<a style="color: #6c7378;
text-decoration: none"
href="{{ host }}/task/{{ task.id }}/log/{{ task.lastRunJobId }}">{{ task.last_run_job_id }}</a>
href="{{ host }}/task/{{ task.id }}#tasklog">{{ task.last_run_job_id }}</a>
</h3>
<!-- message body -->
{% if success == 1 %}
Expand Down
7 changes: 2 additions & 5 deletions runner/web/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def send_email(run_id: int, file_id: int) -> dict:

# send the file

date = str(datetime.datetime.now())
date = datetime.datetime.now()

template = env.get_template("email/email.html.j2")

Expand All @@ -235,10 +235,7 @@ def send_email(run_id: int, file_id: int) -> dict:
+ " / Task: "
+ task.name,
message=template.render(
task=task,
success=1,
date=date,
logs=[],
task=task, success=1, date=date, logs=[], org=app.config["ORG_NAME"]
),
attachments=[x.name for x in downloaded_files],
)
Expand Down
1 change: 1 addition & 0 deletions scheduler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class ConnectionSftp(db.Model):
username = db.Column(db.String(120), nullable=True)
key = db.Column(db.String(8000), nullable=True)
password = db.Column(db.Text, nullable=True)
key_password = db.Column(db.Text, nullable=True)
task = db.relationship(
"Task",
backref="destination_sftp_conn",
Expand Down
1 change: 1 addition & 0 deletions web/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class ConnectionSftp(db.Model):
username = db.Column(db.String(120), nullable=True)
key = db.Column(db.String(8000), nullable=True)
password = db.Column(db.Text, nullable=True)
key_password = db.Column(db.Text, nullable=True)
task = db.relationship(
"Task",
backref="destination_sftp_conn",
Expand Down
17 changes: 14 additions & 3 deletions web/static/assets/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,20 @@

$title-family: 'Rasa', 'Georgia', 'Times New Roman', serif;

$family-sans-serif: 'Inter', -apple-system, 'BlinkMacSystemFont', 'Segoe UI',
'Roboto', 'Helvetica Neue', 'Lucida Sans Unicode', 'Lucida Grande', 'Arial',
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
$family-sans-serif:
'Inter',
-apple-system,
'BlinkMacSystemFont',
'Segoe UI',
'Roboto',
'Helvetica Neue',
'Lucida Sans Unicode',
'Lucida Grande',
'Arial',
sans-serif,
'Apple Color Emoji',
'Segoe UI Emoji',
'Segoe UI Symbol';

@import '../../../node_modules/bulma-checkradio/src/sass';
@import '../../../node_modules/bulma/bulma';
Expand Down
Loading

0 comments on commit de79a5e

Please sign in to comment.