0

How to set python to move the file after complete writing in the server ?

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

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

file.close()

Any right suggestion ? Thank You

Kim
  • 980
  • 1
  • 15
  • 29

1 Answers1

1

You could use the os.rename method:

import os
os.rename('oldPath/Name', 'newPath/Name')

Check out this answer for additional info: How to move a file in Python

Community
  • 1
  • 1
stackPusher
  • 6,076
  • 3
  • 35
  • 36