<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=Monitor_file_continuously</id>
	<title>Monitor file continuously - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=Monitor_file_continuously"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Monitor_file_continuously&amp;action=history"/>
	<updated>2026-05-26T12:09:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Monitor_file_continuously&amp;diff=6983&amp;oldid=prev</id>
		<title>Pyadmin: 2 revisions</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Monitor_file_continuously&amp;diff=6983&amp;oldid=prev"/>
		<updated>2014-03-28T01:53:16Z</updated>

		<summary type="html">&lt;p&gt;2 revisions&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 01:53, 28 March 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Pyadmin</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Monitor_file_continuously&amp;diff=6982&amp;oldid=prev</id>
		<title>Natechols at 22:00, 23 January 2012</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Monitor_file_continuously&amp;diff=6982&amp;oldid=prev"/>
		<updated>2012-01-23T22:00:04Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:00, 23 January 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l37&quot; &gt;Line 37:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 37:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   monitor = pymol_file_monitor(&amp;quot;status.pdb&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   monitor = pymol_file_monitor(&amp;quot;status.pdb&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Script_Library|Monitor file continuously]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:System_Scripts]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Natechols</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Monitor_file_continuously&amp;diff=6981&amp;oldid=prev</id>
		<title>Natechols: Created page with &quot;This script can be used to continuously check the modification timestamp on a file (any format, although this example assumes it's a PDB file), and re-loads it whenever the times...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Monitor_file_continuously&amp;diff=6981&amp;oldid=prev"/>
		<updated>2012-01-23T21:40:31Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This script can be used to continuously check the modification timestamp on a file (any format, although this example assumes it&amp;#039;s a PDB file), and re-loads it whenever the times...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This script can be used to continuously check the modification timestamp on a file (any format, although this example assumes it's a PDB file), and re-loads it whenever the timestamp changes.  As written it is intended to be started from the command line, but this is not a requirement.&lt;br /&gt;
&lt;br /&gt;
= The Code =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import threading&lt;br /&gt;
import time&lt;br /&gt;
import os&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
class pymol_file_monitor (object) :&lt;br /&gt;
  def __init__ (self,&lt;br /&gt;
      file_name, &lt;br /&gt;
      time_wait=1) : # time in seconds between mtime check&lt;br /&gt;
    self.file_name = file_name&lt;br /&gt;
    self.time_wait = time_wait&lt;br /&gt;
    self.watch = True # this can be toggled elsewhere to stop updating&lt;br /&gt;
    self.mtime = 0&lt;br /&gt;
    t = threading.Thread(target=self.check_file)&lt;br /&gt;
    t.setDaemon(1)&lt;br /&gt;
    t.start()&lt;br /&gt;
    print &amp;quot;Watching file %s&amp;quot; % file_name&lt;br /&gt;
&lt;br /&gt;
  def check_file (self) :&lt;br /&gt;
    while (self.watch) :&lt;br /&gt;
      if (os.path.exists(self.file_name)) :&lt;br /&gt;
        print &amp;quot;checking...&amp;quot;&lt;br /&gt;
        mtime = os.path.getmtime(self.file_name)&lt;br /&gt;
        if (mtime &amp;gt; self.mtime) :&lt;br /&gt;
          self.mtime = mtime&lt;br /&gt;
          print &amp;quot;Re-loading %s&amp;quot; % self.file_name&lt;br /&gt;
          cmd.load(self.file_name, state=1)&lt;br /&gt;
      time.sleep(self.time_wait)&lt;br /&gt;
&lt;br /&gt;
if (__name__ == &amp;quot;pymol&amp;quot;) :&lt;br /&gt;
  monitor = pymol_file_monitor(&amp;quot;status.pdb&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Natechols</name></author>
	</entry>
</feed>