Commit 4c1a3d1c authored by cmaffeo2's avatar cmaffeo2
Browse files

Added configuration file, reporting function and version to mrdna package

parent 87a37618
import os
__version__ = "0.1.dev0"
_RESOURCE_DIR = os.path.join(os.path.dirname(__file__), 'resources')
def get_resource_path(relative_path):
return os.path.join(_RESOURCE_DIR, relative_path)
from .segmentmodel import SegmentModel, SingleStrandedSegment, DoubleStrandedSegment
from .simulate import multiresolution_simulation
from .reporting import report
from pathlib import Path
import appdirs
import json
_urlbase = ""
""" Get configuration file for mrdna """
_USER_CONF_DIR = Path(appdirs.user_data_dir())
_USER_CONF_DIR.mkdir(parents=True, exist_ok=True)
_USER_CONF = _USER_CONF_DIR / "mrdna.conf"
if _USER_CONF.exists():
with open(_USER_CONF) as ch:
config = json.load(ch)
config = {}
print("""Thanks for using the multi-resolution DNA modeling package mrdna!
We respect your privacy. We will never collect or share your
information without your explicit permission.
At the same time, we would like to collect anonymous statistics about
the use of the mrdna Python package for reporting to funding agencies
so we can continue to develop and improve these utilities.
For this, we ask for your permission to have the mrdna utility send
your IP address along with information about what part of the mrdna
utility you are using (e.g. cadnano reader, vHelix reader, mrdna
script) to our webserver where it will be stored in a database, along
with geolocation data and a timestamp. Except for your IP adress, no
personally identifiable information will be stored. You are not
required to opt-in to use the mrdna package!
If you have concerns regarding your privacy, please contact the
Aksimentiev group and we will get back to you as soon as we can.""")
while True:
Do you agree to allow the mrdna package can send the information
described above to the Aksimentiev group webserver? [y/N]""")
response = input()
if response in 'y Y yes Yes YES'.split():
print("Permission granted")
config['reporting_allowed'] = True
elif response in 'n N no No NO'.split() + [""]:
print("Permission denied")
config['reporting_allowed'] = False
with open(_USER_CONF,'w') as ch:
import mrdna
import appdirs
from .config import config
def report(data):
if not config['reporting_allowed']:
import requests
import concurrent.futures
import urllib.parse
def send_url(data):
version = urllib.parse.quote_plus(mrdna.__version__)
data = urllib.parse.quote_plus(data)
requests.get(url = "{}/{}".format(version,data))
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment