Skip to content
Snippets Groups Projects
Commit 4c1a3d1c authored by cmaffeo2's avatar cmaffeo2
Browse files

Added configuration file, reporting function and version to mrdna package

parent 87a37618
No related branches found
No related tags found
No related merge requests found
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
report("mrdna.__init__")
from pathlib import Path
import appdirs
import json
_urlbase = "bionano.physics.illinois.edu"
""" 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)
else:
config = {}
print("""Thanks for using the multi-resolution DNA modeling package mrdna!
PRIVACY STATEMENT AND USER AGREEMENT:
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.
mailto:cmaffeo2@illinois.edu""")
while True:
print("""
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
break
elif response in 'n N no No NO'.split() + [""]:
print("Permission denied")
config['reporting_allowed'] = False
break
with open(_USER_CONF,'w') as ch:
json.dump(config,ch)
import mrdna
import appdirs
from .config import config
def report(data):
if not config['reporting_allowed']:
return
try:
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 = "http://bionano.physics.illinois.edu/mrdna-report/{}/{}".format(version,data))
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
executor.submit(send_url,data)
except:
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment