# Path: ddsc/core/ddsapi.py
# class DSResourceNotConsistentError(DataServiceError):
#     """
#     Exception thrown when a DukeDS resource is not in a consistent state.
#     The resource may become consistent at some future point in time so users can retry.
#     """
#     def __init__(self, response, url_suffix, request_data):
#         super(self.__class__, self).__init__(response, url_suffix, request_data)
# 
# class DSHashMismatchError(DataServiceError):
#     """
#     Exception thrown when a DukeDS resource has an incorrect hash.
#     """
#     pass
# 
# class DataServiceError(Exception):
#     """
#     Error that wraps up info about it and creates an informative string.
#     """
#     def __init__(self, response, url_suffix, request_data):
#         """
#         Create exception for failed response.
#         :param response: requests.Response response that was in error
#         :param url_suffix: str url we were trying to connect to
#         :param request_data: object data we were sending to url
#         """
#         resp_json = None
#         try:
#             resp_json = response.json()
#         except:
#             resp_json = {}
#         if response.status_code == 500:
#             if resp_json and not resp_json.get('reason'):
#                 resp_json = {'reason': 'Internal Server Error', 'suggestion': 'Contact DDS support.'}
#         Exception.__init__(self, 'Error {} on {}\nReason:{}\nSuggestion:{}'.format(
#             response.status_code, url_suffix, resp_json.get('reason', resp_json.get('error', '')),
#             resp_json.get('suggestion', '')
#         ))
#         self.response = resp_json
#         self.url_suffix = url_suffix
#         self.request_data = request_data
#         self.status_code = response.status_code


import time
from ddsc.core.ddsapi import DSResourceNotConsistentError, DSHashMismatchError, DataServiceError
from tabulate import tabulate
        return ''


class ProjectChecker(object):

    def __init__(self, config, project):
        self.config = config
        self.project = project

    def files_are_ok(self):
        try:
            self._try_fetch_project_files()
            return True
        except (DSResourceNotConsistentError, DSHashMismatchError):
            return False
        except DataServiceError as e:
            if e.status_code == 400:
                return False
            raise

    def _try_fetch_project_files(self):
        # exhaust the project files generator to fetch urls for all files
        for _, _ in self.project.get_project_files_generator(self.config.page_size):
            pass

    def get_bad_uploads(self):
        results = []
        for remote_path, dds_file in self.project.get_path_to_files().items():
            upload_details = UploadDetails(dds_file, remote_path)
            if upload_details.is_bad():

# Path: ddsc/core/ddsapi.py
# class DSResourceNotConsistentError(DataServiceError):
#     """
#     Exception thrown when a DukeDS resource is not in a consistent state.
#     The resource may become consistent at some future point in time so users can retry.
#     """
#     def __init__(self, response, url_suffix, request_data):
#         super(self.__class__, self).__init__(response, url_suffix, request_data)
# 
# class DSHashMismatchError(DataServiceError):
#     """
#     Exception thrown when a DukeDS resource has an incorrect hash.
#     """
#     pass
# 
# class DataServiceError(Exception):
#     """
#     Error that wraps up info about it and creates an informative string.
#     """
#     def __init__(self, response, url_suffix, request_data):
#         """
#         Create exception for failed response.
#         :param response: requests.Response response that was in error
#         :param url_suffix: str url we were trying to connect to
#         :param request_data: object data we were sending to url
#         """
#         resp_json = None
#         try:
#             resp_json = response.json()
#         except:
#             resp_json = {}
#         if response.status_code == 500:
#             if resp_json and not resp_json.get('reason'):
#                 resp_json = {'reason': 'Internal Server Error', 'suggestion': 'Contact DDS support.'}
#         Exception.__init__(self, 'Error {} on {}\nReason:{}\nSuggestion:{}'.format(
#             response.status_code, url_suffix, resp_json.get('reason', resp_json.get('error', '')),
#             resp_json.get('suggestion', '')
#         ))
#         self.response = resp_json
#         self.url_suffix = url_suffix
#         self.request_data = request_data
#         self.status_code = response.status_code


# Path: ddsc/core/consistency.py
import time
from ddsc.core.ddsapi import DSResourceNotConsistentError, DSHashMismatchError, DataServiceError
from tabulate import tabulate

        return ''


class ProjectChecker(object):

    def __init__(self, config, project):
        self.config = config
        self.project = project

    def files_are_ok(self):
        try:
            self._try_fetch_project_files()
            return True
        except (DSResourceNotConsistentError, DSHashMismatchError):
            return False
        except DataServiceError as e:
            if e.status_code == 400:
                return False
            raise

    def _try_fetch_project_files(self):
        # exhaust the project files generator to fetch urls for all files
        for _, _ in self.project.get_project_files_generator(self.config.page_size):
            pass

    def get_bad_uploads(self):
        results = []
        for remote_path, dds_file in self.project.get_path_to_files().items():
            upload_details = UploadDetails(dds_file, remote_path)
            if upload_details.is_bad():

                results.append(upload_details)