Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- entry_points={
- 'console_scripts':
- ['update = dnurt_integration.program:update']
- }
- $ update
- No such file or directory: 'dnurt_integration/dnurtdb/dbconfig.json'
- from os import system
- from dnurt_integration.scopus import client as sc_client
- from dnurt_integration.web_of_science import client as w_client
- from dnurt_integration.gooscholar import client as g_client
- def update():
- system('clear')
- arg = None
- if sys.argv[1]:
- arg = sys.argv[1]
- if arg == '-s':
- update_scopus()
- elif arg == '-g':
- update_gscholar()
- elif arg == '-w':
- update_wos()
- else:
- update_all()
- def update_scopus():
- print('Updating scopus info...')
- sc_client.update_db()
- print('Done.')
- def update_all():
- update_scopus()
- update_gscholar()
- update_wos()
- def update_gscholar():
- print('Updating gscholar info...')
- # g_client.update_db()
- print('Done.')
- def update_wos():
- print('Updating wos info...')
- # w_client.update_db()
- print('Done.')
- if __name__ == '__main__':
- update()
- db_conf = open("dnurt_integration/dnurtdb/dbconfig.json")
- db_config = json.load(db_conf)
- db_conf.close()
- connect_str = "dbname={0} user={1} password={2}"
- .format(db_config['dbname'], db_config['user'], db_config['password'])
- conn = None
- tables = ('authors',)
- columns = ('id', 'fullname', 'cited_by_count',
- 'citation_count', 'sc_id', 'hirsha', 'doc_count')
- def connect():
- global conn
- try:
- conn = psycopg2.connect(connect_str)
- return True
- except psycopg2.DatabaseError as e:
- print('Error: db connect()', e)
- return False
- def get_cursor():
- return conn.cursor()
- def disconnect():
- global is_connected
- try:
- conn.close()
- is_connected = False
- except:
- print('Error: db connection close()')
- def get_author_ids():
- if connect():
- cursor = get_cursor()
- cursor.execute("""select {0} from {1}""".format(columns[4], tables[0]))
- ids = []
- for id in cursor.fetchall():
- ids.append(id[0])
- return ids
- def scopus_update(author):
- if connect():
- cursor = get_cursor()
- cursor.execute("""update {0} set {1}='{2}', {3}='{4}', {5}='{6}', {7}='{8}', {9}='{10}' where {11}='{12}'"""
- .format(tables[0], columns[1], author.fullname,
- columns[2], author.cited_by_count,
- columns[3], author.citation_count,
- columns[5], author.h_index,
- columns[6], author.doc_count,
- columns[4], author.sc_id))
- conn.commit()
Add Comment
Please, Sign In to add comment