# addresses = Table('addresses', metadata, # Column('id', Integer, primary_key=True), # Column('user_id', None, ForeignKey('users.id')), # Column('email_address', String(50), nullable=False) # ) self.metadata.create_all(self.db_connect) db = Database() table_name = 'DatasetDOI' tables = db.list_table() # db.create_table(table_name) # db.insert_table(table_name) # db.select_table(table_name) csvData = reader.readCSV_pd(csvFile) # for chunk in csvData: # m_uuid = chunk['UUID'] # db.insert_table(table_name, metadata_id=m_id, metadata_uuid=m_uuid) for index, row in csvData.iterrows(): m_id = row['Metadata ID'] m_uuid = row['UUID'] # print(m_id, m_uuid) db.insert_table(table_name, MetadataID=m_id)
msg.attach(part2) # Create a secure SSL context context = ssl.create_default_context() # Try to log in to server and send email try: server = smtplib.SMTP(SMTP_server, PORT) server.starttls(context=context) # Secure the connection # Login to Email server.login(args[0], PASSWORD) # Send Email server.sendmail(args[0], args[1], msg.as_string()) print("Email sent to {}".format(args[1])) except Exception as e: # Print any error messages to stdout print("Login Failed ...", e) finally: server.quit() csvData = CSV.readCSV_pd(csvFile) for index, row in csvData.iterrows(): name = row['name'] email = row['email'] # print(name, email) sendEmail(senderEmail, email, name)
GN_Login.gn_login() search_result = 0 print("Searching Metadata...") gn_conn = GN_Login.gn_session.post(GN_Login.gn_search, data=xml_search, headers=GN_Login.xml_header) meta_xml = xml.dom.minidom.parseString(gn_conn.text) gn_uuid = meta_xml.getElementsByTagName("uuid") gn_id = meta_xml.getElementsByTagName("id") get_meta(gn_uuid, search_result_UUID) get_meta(gn_id, search_result_ID) GN_Login.gn_logout() for x, y in zip(search_result_ID, search_result_UUID): try: search_result = search_result + 1 except ValueError as e: print(e) print("Metadata Search Result: ", search_result) gn_search_metadata() Search = {'Metadata ID': search_result_ID, 'UUID': search_result_UUID} # print(search_result_ID, search_result_UUID) CSV_Read_Write.writeCSV_pd(outputFile, **Search)
id_info.append(metadata_id) uuid_info.append(metadata_uuid) title_info.append(metadata_title) date_info.append(metadata_year) author_info.append(metadata_author) abstract_info.append(metadata_abstract) purpose_info.append(metadata_purpose) link_info.append(metadata_link) except IOError: print(sys.exc_info()[0], "Error in accessing metadata with ID :" + str(m_id)) csvData = CSV_Read_Write.readCSV_pd(csvFile) GN_Login.gn_login() for index, row in csvData.iterrows(): m_id = row['Metadata ID'] m_uuid = row['UUID'] # print(row['Metadata ID'], row['UUID']) getInfo(m_id, m_uuid) GN_Login.gn_logout() Information = { 'ID': id_info, 'UUID': uuid_info, 'Title': title_info, 'Date': date_info, 'Author': author_info, 'Abstract': abstract_info,
GN_CONN = GN_Login.gn_session.post(GN_Login.gn_getURL, data=getXml, headers=GN_Login.xml_header) # Parsing xml metadataXML = minidom.parseString(GN_CONN.text) updateXML = updateNode(metadataXML, args[2]) update_gn_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\ <request><id>" + str(args[0]) + "</id><version>1</version>\ <data><![CDATA[" + updateXML.toxml() + "]]></data></request>" # print(update_gn_xml) GN_CONN = GN_Login.gn_session.post(GN_Login.gn_update, data=update_gn_xml, headers=GN_Login.xml_header) print("Metadata Updated...", args[0], GN_CONN) except IOError: print(sys.exc_info()[0], "Error in accessing metadata with ID :" + str(m_id)) csvData = CSV_Read_Write.readCSV_pd(csvFile) GN_Login.gn_login() for index, row in csvData.iterrows(): m_id = row['Metadata ID'] m_uuid = row['UUID'] m_doi = row['DOI'] getInfo(m_id, m_uuid, m_doi) GN_Login.gn_logout()
ErList = [] # check metadata link list csvFile = "DownloadListRDS.csv" # generate error list of N/A metadata outputFile = "Metadata_ERRORLIST.csv" def checkLink(args): URL = 'http://rds.icimod.org/Home/DataDetail?metadataId=' + str(args) response = requests.get(URL) # print(response.status_code) if not response.status_code == 200: print("Not Found.", URL) ErList.append(URL) # else: # print(" Working") csvData = CSV_Read_Write.readCSV_pd(csvFile) for index, row in csvData.iterrows(): m_id = row['MetadataID'] m_uuid = row['MetadataUUID'] checkLink(m_id) heading = {'ErrorLink': ErList} CSV_Read_Write.writeCSV_pd(outputFile, **heading)