# Path: grace/utils.py
# def get_path():
#     encoding = sys.getfilesystemencoding()
#     if we_are_frozen():
#         return os.path.dirname(sys.executable)
#     return os.path.dirname(__file__)
# 
# def write_json(string):
#     try:
#         return json.dumps(string)
#     except:
#         raise
# 
# Path: grace/error.py
# class MissingKeyError(Error):
#     pass
# 
# class WrongLoginCredentials(Error):
#     pass
# 
# class FileNotFoundError(Error):
#     pass
# 
# class RemoteServerError(Error):
#     pass


from builtins import input
from builtins import object
from .utils import get_path, write_json
from .error import MissingKeyError, WrongLoginCredentials, FileNotFoundError, RemoteServerError
from pkg_resources import resource_filename
import os
import requests
import getpass
from __future__ import print_function
from __future__ import absolute_import

requests.packages.urllib3.disable_warnings()


class Upload(object):
    def __init__(self, config):
        self._cwd = os.getcwd()
        self._root = get_path()
        self._config = config
        self._verify_ssl = False

        self._username = None
        self._password = None

        self._check_config()

    def _check_config(self):
        if 'urls' not in self._config:
            raise MissingKeyError('Could not find url settings in either global or local configuration file.')

        if 'upload' not in self._config['urls']:

# Path: grace/utils.py
# def get_path():
#     encoding = sys.getfilesystemencoding()
#     if we_are_frozen():
#         return os.path.dirname(sys.executable)
#     return os.path.dirname(__file__)
# 
# def write_json(string):
#     try:
#         return json.dumps(string)
#     except:
#         raise
# 
# Path: grace/error.py
# class MissingKeyError(Error):
#     pass
# 
# class WrongLoginCredentials(Error):
#     pass
# 
# class FileNotFoundError(Error):
#     pass
# 
# class RemoteServerError(Error):
#     pass


# Path: grace/upload.py
from builtins import input
from builtins import object
from .utils import get_path, write_json
from .error import MissingKeyError, WrongLoginCredentials, FileNotFoundError, RemoteServerError
from pkg_resources import resource_filename
import os
import requests
import getpass

from __future__ import print_function
from __future__ import absolute_import

requests.packages.urllib3.disable_warnings()


class Upload(object):
    def __init__(self, config):
        self._cwd = os.getcwd()
        self._root = get_path()
        self._config = config
        self._verify_ssl = False

        self._username = None
        self._password = None

        self._check_config()

    def _check_config(self):
        if 'urls' not in self._config:
            raise MissingKeyError('Could not find url settings in either global or local configuration file.')

        if 'upload' not in self._config['urls']:

            raise MissingKeyError('Could not find an upload url in either the global or local configuration file.')