def execute(self, context):
     samba = SambaHook(samba_conn_id=self.samba_conn_id)
     hive = HiveServer2Hook(hiveserver2_conn_id=self.hiveserver2_conn_id)
     tmpfile = tempfile.NamedTemporaryFile()
     _log.info("Fetching file from Hive")
     hive.to_csv(hql=self.hql, csv_filepath=tmpfile.name)
     _log.info("Pushing to samba")
     samba.push_from_local(self.destination_filepath, tmpfile.name)
Exemplo n.º 2
0
 def execute(self, context):
     samba = SambaHook(samba_conn_id=self.samba_conn_id)
     hive = HiveServer2Hook(hiveserver2_conn_id=self.hiveserver2_conn_id)
     tmpfile = tempfile.NamedTemporaryFile()
     self.log.info("Fetching file from Hive")
     hive.to_csv(hql=self.hql, csv_filepath=tmpfile.name)
     self.log.info("Pushing to samba")
     samba.push_from_local(self.destination_filepath, tmpfile.name)
 def execute(self, context):
     with NamedTemporaryFile() as tmp_file:
         self.log.info("Fetching file from Hive")
         hive = HiveServer2Hook(hiveserver2_conn_id=self.hiveserver2_conn_id)
         hive.to_csv(hql=self.hql, csv_filepath=tmp_file.name, hive_conf=context_to_airflow_vars(context))
         self.log.info("Pushing to samba")
         samba = SambaHook(samba_conn_id=self.samba_conn_id)
         samba.push_from_local(self.destination_filepath, tmp_file.name)
Exemplo n.º 4
0
 def execute(self, context):
     samba = SambaHook(samba_conn_id=self.samba_conn_id)
     hive = HiveServer2Hook(hiveserver2_conn_id=self.hiveserver2_conn_id)
     with NamedTemporaryFile() as tmp_file:
         self.log.info("Fetching file from Hive")
         hive.to_csv(hql=self.hql, csv_filepath=tmp_file.name,
                     hive_conf=context_to_airflow_vars(context))
         self.log.info("Pushing to samba")
         samba.push_from_local(self.destination_filepath, tmp_file.name)
Exemplo n.º 5
0
    def execute(self, context):
        """
        Picks up all files from a source directory and dumps them into a root directory system,
        organized by dagid, taskid and execution_date
        For anonimous username = '******' and password = '******'.
        """
        execution_date = context['execution_date'].strftime(DATE_FORMAT)
        #source_dir = src_hook.get_path()
        #SOme info: self.dag.dag_id, self.task_id
        loging.info("{0} Execution copy file from FTP to Samba Share".format(execution_date))
        if not self.src_conn_id:
            raise AirflowException("Cannot operate without src_conn_id.")
        if not self.dst_conn_id:
            raise AirflowException("Cannot operate without dst_conn_id.")
        src_hook = FTPHook(conn_id=self.src_conn_id)              
        dst_hook = SambaHook(samba_conn_id=self.dst_conn_id)
        #samba.push_from_local(self.destination_filepath, tmp_file.name) 
        
        if not self.src_filename and self.dest_filename:
            raise AirflowException("FtpToSambaOperator: dest_filename specified but no src_filename.")
        
        if not self.src_filename:
            src_hook.