You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/04/02 22:10:07 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #15134: add loggin.info when poke in SFTP,FTP and Filesystem sensor to show last modified

kaxil commented on a change in pull request #15134:
URL: https://github.com/apache/airflow/pull/15134#discussion_r606449285



##########
File path: airflow/sensors/filesystem.py
##########
@@ -57,6 +58,9 @@ def poke(self, context):
 
         for path in glob(full_path):
             if os.path.isfile(path):
+                mod_time = os.path.getmtime(path)
+                mod_time = datetime.datetime.fromtimestamp(mod_time).strftime('%Y%m%d%H%M%S')

Review comment:
       ```suggestion
                   mod_time = datetime.datetime.fromtimestamp(mod_time)
   ```
   
   otherwise, we will get `20210401160147` (which isn't that readable)
   
   The default is anyways good enough:
   
   ```python
   >>> str(datetime.datetime.fromtimestamp(os.path.getmtime("some_file.txt")))
   '2021-04-01 16:01:47.227895'
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org