A mistake to ask

  1. #encoding:cp936
  2. '''
  3. Created on December 13, 2013

  4. @author: Administrator
  5. '''

  6. from neiwangfabu2 import *
  7. import os
  8. import fnmatch
  9. import shutil
  10. cptodir=r"E:\ version \ script distribution system 4"
  11. #dir_2=r"E:\ version \ script distribution system 4\Lua"

  12. def removDir():
  13. os.chdir(cptodir)
  14. src_dir=os.getcwd()
  15. print src_dir
  16. src_dir_list=os.listdir(src_dir)
  17. for src_dir_file in src_dir_list:
  18. #print src_dir_file
  19. if os.path.isdir(src_dir_file):
  20. shutil.rmtree(src_dir_file)

  21. def cpDir():
  22. os.chdir(cptodir)
  23. mod_file="modules"
  24. if not os.path.isdir(mod_file):os.mkdir(mod_file)
  25. mod_file_over=os.path.join(cptodir,mod_file)
  26. print mod_file_over
  27. res_file="resource"
  28. if not os.path.isdir(res_file):os.mkdir(res_file)
  29. res_file_over=os.path.join(cptodir,res_file)
  30. print res_file_over
  31. os.chdir(unziptodir)
  32. zip_file_list=os.listdir(unziptodir)
  33. for zip_file_all in zip_file_list:
  34. if zip_file_all[-3:]==".so":
  35. print zip_file_all
  36. shutil.copy(zip_file_all, os.path.join(mod_file_over,zip_file_all))
  37. elif zip_file_all=="Lua":
  38. print zip_file_all
  39. shutil.copytree(zip_file_all, os.path.join(cptodir,zip_file_all))
  40. print os.getcwd()

  41. elif zip_file_all[-4:]==".zip":
  42. print "Zip_file_all is: %s" %zip_file_all
  43. data_file=zip_file_all[:-4]
  44. print "Data_file is:%s" %data_file
  45. os.chdir(data_file)
  46. print os.getcwd()
  47. data_file_list=os.listdir(os.getcwd())
  48. print "Data_file_list is:%s" %data_file_list
  49. for data_file_all in data_file_list:
  50. if data_file_all=="XMLData":
  51. print "Data_file_all is:%s" %data_file_all
  52. shutil.copytree(data_file_all,os.path.join(cptodir,data_file_all))
  53. elif data_file_all=="map":
  54. shutil.copy(data_file_all, os.path.join(res_file_over,data_file_all))
  55. elif data_file_all=="xml":
  56. shutil.copy(data_file_all, os.path.join(res_file_over,data_file_all))


  57. if __name__=='__main__':
  58. removDir()
  59. print "Directory empty"
  60. cpDir()
  61. print "File copy completed"


Error message
  1. E:\ version \ script distribution system 4
  2. Directory empty
  3. E:\ version \ script distribution system 4\modules
  4. E:\ version \ script distribution system 4\resource
  5. Zip_file_all is: Data12.12.zip
  6. Data_file is: Data12.12
  7. E:\ version \ intranet platform \rpgserver22\aa\Data12.12
  8. Data_file_list is:['abc', 'map', 'xml', 'XMLData']
  9. Traceback (most recent call last):
  10. File "E:\ Baidu cloud synchronous disk \python\sprout\neiwangfabu3.py", line 67, in <module>
  11. cpDir()
  12. File "E:\ Baidu cloud synchronous disk \python\sprout\neiwangfabu3.py", line 59, in cpDir
  13. shutil.copy(data_file_all, os.path.join(res_file_over,data_file_all))
  14. File "C:\Python26\lib\shutil.py", line 84, in copy
  15. copyfile(src, dst)
  16. File "C:\Python26\lib\shutil.py", line 50, in copyfile
  17. with open(src, 'rb') as fsrc:
  18. IOError: [Errno 13] Permission denied: 'map'
Don't know where is the problem, because if I am a single operation is possible execution copy command
Such as this:
QQ screenshot 20131214154702.png

This is don't know. .
Please advice. .

Started by Dylan at February 06, 2016 - 11:06 PM

The program runs and terminal input effect is sometimes not the same, program debugging and running effect is sometimes not the same, if debugging cannot reproduce the bug requires logging lose out to judge.
Debugging is one of the basic skills, Python language is very good for debugging support (unlike PHP such rubbish), your own debugging program.
Again recommend Pycharm (the best free Python IDE (no one))

Posted by Adolph at February 10, 2016 - 11:45 PM

Your map is a file or folder? Why do you XMLData is used by copytree and map using copy?

Posted by Tommy at February 23, 2016 - 12:44 AM

All right, get

Posted by Dylan at March 05, 2016 - 1:16 AM

Done a good solution

Posted by Tommy at March 20, 2016 - 1:55 AM

In fact, the judge is to put a layer of
  1. for zip_file_all in zip_file_list:
  2. if zip_file_all[-4:]==".zip":
  3. print "Now copy the configuration files to release path..."
  4. data_file=zip_file_all[:-4]
  5. os.chdir(data_file)
  6. data_file_list=os.listdir(os.getcwd())
  7. for data_file_all in data_file_list:
  8. if data_file_all=="XMLData":
  9. if os.path.exists(os.path.join(res_file_over,data_file_all)):continue
  10. shutil.copytree(data_file_all,os.path.join(cptodir,data_file_all))

  11. for data_file_all in data_file_list:
  12. if data_file_all=="map":
  13. shutil.copytree(data_file_all, os.path.join(res_file_over,data_file_all))
  14. for data_file_all in data_file_list:
  15. if data_file_all=="xml":
  16. shutil.copytree(data_file_all, os.path.join(res_file_over,data_file_all))

Posted by Dylan at March 29, 2016 - 2:49 AM