Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import datetime
- import threading
- from subprocess import Popen
- today = datetime.date.today()
- os.makedirs("C:/newscript_image/" + str(today))
- class myThread(threading.Thread):
- def run(self):
- for filename in os.listdir('./newscript/'):
- if '.htm' in filename:
- name = filename.strip('.htm')
- dbfolder = "C:/newscript/db/" + name
- os.makedirs(dbfolder)
- Popen("python.exe C:/execution.py" + ' ' + filename + ' ' + name + ' ' + str(today) + ' ' + dbfolder)
- myThread().start()
- import multiprocessing
- import execution
- import datetime
- #assume we have a function:
- #exection.run_main_with_args(filename,name,today_str,dbfolder)
- today = datetime.datetime.today()
- def my_execute(filename):
- if '.htm' in filename:
- name = filename.strip('.htm')
- dbfolder = "C:/newscript/db/" + name
- os.makedirs(dbfolder)
- execution.run_main_with_args(filename,name,str(today),dbfolder)
- p = multiprocessing.Pool()
- p.map(my_execute,list_of_files_to_process)
- #!/usr/bin/env python
- import os
- import threading
- from subprocess import Popen
- class myThread(threading.Thread):
- def run(self):
- for filename in os.listdir("./newscript/"):
- if '.htm' in filename:
- Popen("./busy.sh")
- myThread().start()
- #!/usr/bin/env bash
- while :
- do
- uptime >> $$
- sleep 1
- done
- import subprocess
- def run_main_with_args(filename,name,today,dbfolder):
- print('{} {} {}'.format('nfilename: ',filename, ''))
- print('{} {} {}'.format('name: ',name, ''))
- print('{} {} {}'.format('today: ',today, ''))
- print('{} {} {}'.format('dbfolder: ',dbfolder, ''))
- outfile = dbfolder+ '/' + name + '.txt'
- with open (outfile, 'w') as fout:
- print('name', file=fout)
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # Author : Bhishan Poudel; Physics Graduate Student, Ohio University
- # Date : Aug 29, 2016
- #
- # Imports
- import multiprocessing,os,subprocess
- import datetime
- import execution # file: execution.py
- #assume we have a function:
- #exection.run_main_with_args(filename,name,today_str,dbfolder)
- today = datetime.datetime.today()
- def my_execute(filename):
- if '.txt' in filename:
- name = filename.strip('.txt')
- dbfolder = "db/" + name
- if not os.path.exists(dbfolder): os.makedirs(dbfolder)
- execution.run_main_with_args(filename,name,str(today),dbfolder)
- p = multiprocessing.Pool()
- p.map(my_execute,['file1.txt', 'file2.txt'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement