Python - How to move the file after complete writing
<p>How to set python to move the file after complete writing in the server ?</p>

<p>Below is my same to lock the file after complete writing, but it does'nt work in Linux server.</p>

<pre><code>try:
   fcntl.lockf(file2,fcntl.LOCK_EX|fcntl.LOCK_NB)
   print "Yes Locked"
   time.sleep(20)
except:
    print "No Lock"

file.close()
</code></pre>

<p>Any right suggestion ? Thank You</p>

<p>You could use the os.rename method:</p>

<pre><code>import os
os.rename('oldPath/Name', 'newPath/Name')
</code></pre>

<p>Check out this answer for additional info:
<a href="http://stackoverflow.com/questions/8858008/how-to-move-a-file-in-python">How to move a file in Python</a></p>

python linux