Skip to content

Commit

Permalink
Added SSH tunnel handling.
Browse files Browse the repository at this point in the history
added geo file upload function.
  • Loading branch information
fccoelho committed Dec 29, 2021
1 parent aaa5fd3 commit b2e27a6
Show file tree
Hide file tree
Showing 8 changed files with 456 additions and 3 deletions.
36 changes: 36 additions & 0 deletions epigraphhub_py/connection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import atexit

from sshtunnel import SSHTunnelForwarder


class Tunnel:
def __init__(self):
self.host = "epigraphhub.org"
self.server = None
atexit.register(self.close_tunnel)

def open_tunnel(self, user="epigraph", ssh_key_passphrase=""):
"""
Opens a tunnel to EpigraphHub database
"""
self.server = SSHTunnelForwarder(
self.host,
ssh_username=user,
ssh_password="epigraph",
ssh_private_key_password=ssh_key_passphrase,
remote_bind_address=("127.0.0.1", 5432),
)

self.server.start()

def __repr__(self):
if self.server is None:
return "Tunnel is closed."
else:
return f"Port {self.server.local_bind_port} is being forwarded to {self.host}:5432"

def close_tunnel(self):
if not self.server is None:
print("Closing Tunnel...")
self.server.stop()
self.server = None
File renamed without changes.
3 changes: 3 additions & 0 deletions epigraphhub_py/epigraphhub/analysis/rtestim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import arviz as az
import pandas as pd
import pymc3 as pm
Empty file.
6 changes: 6 additions & 0 deletions epigraphhub_py/epigraphhub/data/upload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import geopandas as gpd
import pandas as pd


def upload_geo_file(fname):
gdf = gpd.read_file(fname)
Loading

0 comments on commit b2e27a6

Please sign in to comment.