Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. import os
  2. import datetime
  3. import threading
  4. from subprocess import Popen
  5.  
  6. today = datetime.date.today()
  7. os.makedirs("C:/newscript_image/" + str(today))
  8.  
  9. class myThread(threading.Thread):
  10. def run(self):
  11. for filename in os.listdir('./newscript/'):
  12. if '.htm' in filename:
  13. name = filename.strip('.htm')
  14.  
  15. dbfolder = "C:/newscript/db/" + name
  16. os.makedirs(dbfolder)
  17.  
  18. Popen("python.exe C:/execution.py" + ' ' + filename + ' ' + name + ' ' + str(today) + ' ' + dbfolder)
  19. myThread().start()
  20.  
  21. import multiprocessing
  22. import execution
  23. import datetime
  24.  
  25. #assume we have a function:
  26. #exection.run_main_with_args(filename,name,today_str,dbfolder)
  27.  
  28. today = datetime.datetime.today()
  29. def my_execute(filename):
  30. if '.htm' in filename:
  31. name = filename.strip('.htm')
  32. dbfolder = "C:/newscript/db/" + name
  33. os.makedirs(dbfolder)
  34. execution.run_main_with_args(filename,name,str(today),dbfolder)
  35.  
  36. p = multiprocessing.Pool()
  37. p.map(my_execute,list_of_files_to_process)
  38.  
  39. #!/usr/bin/env python
  40.  
  41. import os
  42. import threading
  43. from subprocess import Popen
  44.  
  45. class myThread(threading.Thread):
  46. def run(self):
  47. for filename in os.listdir("./newscript/"):
  48. if '.htm' in filename:
  49. Popen("./busy.sh")
  50.  
  51. myThread().start()
  52.  
  53. #!/usr/bin/env bash
  54. while :
  55. do
  56. uptime >> $$
  57. sleep 1
  58. done
  59.  
  60. import subprocess
  61.  
  62.  
  63. def run_main_with_args(filename,name,today,dbfolder):
  64. print('{} {} {}'.format('nfilename: ',filename, ''))
  65. print('{} {} {}'.format('name: ',name, ''))
  66. print('{} {} {}'.format('today: ',today, ''))
  67. print('{} {} {}'.format('dbfolder: ',dbfolder, ''))
  68.  
  69. outfile = dbfolder+ '/' + name + '.txt'
  70. with open (outfile, 'w') as fout:
  71. print('name', file=fout)
  72.  
  73. #!/usr/bin/env python
  74. # -*- coding: utf-8 -*-
  75. #
  76. # Author : Bhishan Poudel; Physics Graduate Student, Ohio University
  77. # Date : Aug 29, 2016
  78. #
  79.  
  80. # Imports
  81. import multiprocessing,os,subprocess
  82. import datetime
  83. import execution # file: execution.py
  84.  
  85. #assume we have a function:
  86. #exection.run_main_with_args(filename,name,today_str,dbfolder)
  87.  
  88. today = datetime.datetime.today()
  89. def my_execute(filename):
  90. if '.txt' in filename:
  91. name = filename.strip('.txt')
  92. dbfolder = "db/" + name
  93. if not os.path.exists(dbfolder): os.makedirs(dbfolder)
  94. execution.run_main_with_args(filename,name,str(today),dbfolder)
  95.  
  96.  
  97.  
  98. p = multiprocessing.Pool()
  99. p.map(my_execute,['file1.txt', 'file2.txt'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement