#!/usr/bin/python from bs4 import BeautifulSoup import sys import re import time import csv import subprocess #time.sleep(2) counter = 0 DetectorNum = 1 soup = BeautifulSoup(open('/usr/local/elog/logbooks/Table.html'), 'html5lib') for table in soup.find_all('table'): for row in table.find_all('tr'): col = row.find_all('td') Xia = col[0].string module = col[1].string channel = col[2].string name = col[3].string arrayPos = col[4].string panel = col[5].string if counter == 0: titleList = (str(Xia), str(module), str(channel), str(name), str(arrayPos), str(panel)) counter = counter + 1 else: record = (str(Xia), str(module), str(channel), str(name), str(arrayPos), str(panel)) file = open('/usr/local/elog/logbooks/tableData', 'w') for i in range(len(titleList)): file.write(str(titleList[i])+" = "+str(record[i])+"\n") file.close() DetName = "C"+str(DetectorNum) subprocess.call(["elog", "-h", "localhost", "-p", "8080", "-l", DetName, "-u", "System", "password", "-a", "Author=System", "-a", "Subject=\"testing the auto writing of detectors\"", "-m", "/usr/local/elog/logbooks/tableData"]) counter = counter + 1 DetectorNum = DetectorNum + 1