<div dir="auto">If I&#39;m reading it correctly, it&#39;s a 5 hr difference?  Local vs gmt?<div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 4, 2021, 6:43 PM Bruce Labitt &lt;<a href="mailto:bruce.labitt@myfairpoint.net">bruce.labitt@myfairpoint.net</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div>
    <p>This is an odd question.  It involves both python and linux.</p>
    <p>Have a bunch of files in a directory that I&#39;d like like to sort
      by similar names and in time order.  This isn&#39;t particularly
      difficult in python.  What is puzzling me is the modified
      timestamp returned by python doesn&#39;t match whats reported by the
      file manager nautilus or even ls.  (ls and nautilus are
      consistent)<br>
    </p>
    <font size="+1" face="monospace">$ lsb_release -d Ubuntu 20.04.2 LTS</font><font size="+1"><br>
      <font face="monospace">$ nautilus --version  GNOME nautilus 3.36.3</font><br>
    </font>
    <p><font size="+1"><font face="monospace">$ python3 --version 
          Python 3.8.5</font></font></p>
    <p><font size="+1"><font face="monospace">$ ls -lght</font></font></p>
    <font size="+1"><font face="monospace">total 4.7M<br>
        -rw-r--r-- 1 bruce 209K Feb 26 01:49 20210226_022134_PLD.edf<br>
        -rw-r--r-- 1 bruce  65K Feb 26 01:49 20210226_022134_SAD.edf<br>
        -rw-r--r-- 1 bruce 2.4M Feb 26 01:49 20210226_022133_BRP.edf<br>
        -rw-r--r-- 1 bruce 1.1K Feb 26 00:58 20210225_224134_EVE.edf<br>
        -rw-r--r-- 1 bruce 1.9M Feb 25 21:18 20210225_224141_BRP.edf<br>
        -rw-r--r-- 1 bruce 169K Feb 25 21:17 20210225_224142_PLD.edf<br>
        -rw-r--r-- 1 bruce  53K Feb 25 21:17 20210225_224142_SAD.edf<br>
        <br>
      </font></font>
    <p>Python3 script</p>
    <p><font size="+1" face="monospace">#!/usr/bin/env python3<br>
        import os<br>
        from datetime import datetime<br>
        <br>
        def convert_date(timestamp):<br>
          d = datetime.utcfromtimestamp(timestamp)<br>
          formatted_date = d.strftime(&#39;%d %b %Y  %H:%M:%S&#39;)<br>
          return formatted_date<br>
        <br>
        with os.scandir(&#39;feb262021&#39;) as entries:<br>
          for entry in entries:<br>
            if entry.is_file():<br>
              info = entry.stat()<br>
              print(f&#39;{<a href="http://entry.name" target="_blank" rel="noreferrer">entry.name</a>}\t Last Modified:
        {convert_date(info.st_mtime) }&#39; )  # last modification</font><br>
    </p>
    <p>info <i>(after exit) contains</i>: <font size="+1" face="monospace">os.stat_result(st_mode=33188, st_ino=34477637,
        st_dev=66306, st_nlink=1, st_uid=1000, st_gid=1000,
        st_size=213416, st_atime=1614379184, st_mtime=1614322176,
        st_ctime=1614379184)</font></p>
    <p><font size="+1">Running the script results in: </font><br>
    </p>
    <p><font face="monospace">20210226_022133_BRP.edf     Last Modified:
        26 Feb 2021  06:49:34<br>
        20210225_224141_BRP.edf     Last Modified: 26 Feb 2021  02:18:42<br>
        20210225_224142_PLD.edf     Last Modified: 26 Feb 2021  02:17:44<br>
        20210225_224142_SAD.edf     Last Modified: 26 Feb 2021  02:17:44<br>
        20210225_224134_EVE.edf     Last Modified: 26 Feb 2021  05:58:26<br>
        20210226_022134_SAD.edf     Last Modified: 26 Feb 2021  06:49:36<br>
        20210226_022134_PLD.edf     Last Modified: 26 Feb 2021  06:49:36<br>
      </font></p>
    <p>Actually, what is returned by my script is at least sensible,
      given that <font face="monospace">20210225_224141_BRP.edf</font>
      started on Feb 25th and ended recording at 2:17am on Feb 26th.  I
      know this because I can see the data on a separate program.  <font face="monospace">20210226_022133_BRP.edf </font>started on Feb
      26th at around 2:21am and terminated at 6:49am.  BRP files are
      written to continuously at a 25 Hz rate all evening.  What makes
      no sense whatsoever is what <b>ls</b> is reporting.</p>
    <p>Do <b>ls</b> and python3 use different definitions of &quot;last
      modified&quot;?</p>
    <p>Guess I can keep going, but I really was surprised at the
      difference between methods.  Default for ls is &quot;last modified&quot;, at
      least as reported by man.  ls&#39;s last modified just isn&#39;t correct,
      at least on Ubuntu 20.04.2</p>
    <p>Is this a quirk?  Am I doing something wrong?  Some kind of
      voodoo definition of &quot;last modified&quot;?  What does Linux say &quot;last
      modified&quot; really means?</p>
    <p>FWIW, I am coming up to speed on processing these edf files to
      help out on an open source project.  Been working on some data
      analysis tools.  As an aside, biological data is very messy.  It&#39;s
      been a treat to work on this as it&#39;s forced me to dust off the
      mental cobwebs and work on a problem that can help a lot of
      people.<br>
    </p>
    <p><br>
    </p>
  </div>

_______________________________________________<br>
gnhlug-discuss mailing list<br>
<a href="mailto:gnhlug-discuss@mail.gnhlug.org" target="_blank" rel="noreferrer">gnhlug-discuss@mail.gnhlug.org</a><br>
<a href="http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/" rel="noreferrer noreferrer" target="_blank">http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/</a><br>
</blockquote></div>