Esempio n. 1
0
 def __init__(self, config_file):
     """
     get googledoc-config.json file content and then initialize storage client
     """
     logging = initialize_logger()
     # Get the logger specified in the file
     self.logger = logging.getLogger(__name__)
     self.storage_client = storage.Client.from_service_account_json(
         config_file)
 def __init__(self, aws_access_key, aws_secret_key):
     """
     Intialize s3 client
     """
     logging = initialize_logger()
     # Get the logger specified in the file
     self.logger = logging.getLogger(__name__)
     self.s3_client = boto3.resource("s3",
                                     aws_access_key_id=aws_access_key,
                                     aws_secret_access_key=aws_secret_key
                                     )
     self.bucket_resource = self.s3_client
    def __init__(self):
        """
        get googledoc-config.json file content and then save this dtaa to class config variable
        """
        logging = initialize_logger()
        # Get the logger specified in the file
        self.logger = logging.getLogger(__name__)

        with open(os.path.dirname(__file__) + '/config.json') as json_file:
            config = json.load(json_file)
            self.config = config
        self.raw_data = None
        self.tags = None
    def __init__(self, plugin, config):
        try:
            PDFPlugin.verify(type(plugin))
            logging = initialize_logger()
            # Get the logger specified in the file
            self.logger = logging.getLogger(__name__)
            self._plugin = plugin
            self._config = Config(config=config)
            self._app = get_db()

        except:
            self.logger.error("Exception occurred", exc_info=True)
            raise ValueError(
                'Please provide a valid plugin. Needs to be an instance of PDFPlugin.'
            )
"""
Cron for regernating file url
"""
import os
import os.path
import calendar
import time
from db.app import DB, create_app
from db.models import PdfData, OutputTable
from utils.func import initialize_logger, info_log, print_log
from plugin.file_uploader.file_uploader import FileUploader
from plugin.odk_plugin.external import ODKSheetsPlugin

logging = initialize_logger()
# Get the logger specified in the file
logger = logging.getLogger(__name__)

app = create_app()
if __name__ == '__main__':
    #app.run(debug=True)

    with app.app_context():
        cur_time = calendar.timegm(time.gmtime())
        qms = PdfData.query.filter(PdfData.url_expires < cur_time,
                                   PdfData.long_doc_url != '').all()
        if qms:
            try:
                i = 0
                results = []
                data = dict()
                for data in qms: