Browse Source

Extracted site specific configuration in config.py

Andreas Kopmann 7 years ago
parent
commit
b388290e39
6 changed files with 13 additions and 15 deletions
  1. 2 1
      ak_wordpress.py
  2. 1 6
      scopus-get-publications.py
  3. 3 5
      scopus-update-database.py
  4. 3 1
      test-wp.py
  5. 4 2
      test-wp2.py
  6. 0 0
      update.sh

+ 2 - 1
ak_wordpress.py

@@ -10,9 +10,10 @@ from wordpress_xmlrpc import WordPressPost, WordPressComment
 from wordpress_xmlrpc.methods.posts import GetPost, NewPost, EditPost
 from wordpress_xmlrpc.methods.comments import NewComment, EditComment
 
+from config import *
 
 # Use Wordpress account - not the mysql credentials
-wp = Client('http://localhost/~kopmann/ufo2/xmlrpc.php', 'scopus', '$scopus$')
+wp = Client(wp_api_url, wp_user, wp_password) 
 
 
 #

+ 1 - 6
scopus-get-publications.py

@@ -32,12 +32,7 @@ from ak_wordpress import wordpress_post_by_scopus, wordpress_comment_by_scopus,
 import pymysql.cursors
 import pymysql
 
-db_host = 'localhost'
-db_user = 'scopus'
-db_pw = '$scopus$'
-db_name = 'scopus'
-
-log_file = '/Users/kopmann/scopus-publications.log'
+from config import *
 
 
 # Summary

+ 3 - 5
scopus-update-database.py

@@ -22,10 +22,7 @@ from ak_wordpress import wordpress_post_by_scopus, wordpress_comment_by_scopus,
 import pymysql.cursors
 import pymysql
 
-db_host = 'localhost'
-db_user = 'scopus'
-db_pw = '$scopus$'
-db_name = 'scopus'
+from config import *
 
 
 # Summary
@@ -38,6 +35,7 @@ npubs = 0
 # - Update categories for author groups in wordpress
 #
 def update_database():
+    global npubs
     
     print "=== Check validity of publications database "
     
@@ -48,7 +46,7 @@ def update_database():
     try:
         with connection.cursor() as cursor:
             
-            sql = "SELECT wpid FROM `publications`"
+            sql = "SELECT wpid FROM `publications` WHERE wpid > 0"
             cursor.execute(sql)
             
             result = cursor.fetchall()

+ 3 - 1
test-wp.py

@@ -10,9 +10,11 @@ from wordpress_xmlrpc.methods.posts import GetPosts, NewPost, EditPost
 from wordpress_xmlrpc.methods.comments import NewComment, EditComment
 from wordpress_xmlrpc.methods.users import GetUserInfo
 
+from config import *
+
 # Use Wordpress account - not the mysql credentials
 # Todo: use scopus later !!!
-wp = Client('http://localhost/~kopmann/ufo2/xmlrpc.php', 'ufo', '$ipepdv$')
+wp = Client(wp_api_url,wp_user,wp_password)
 #print wp.call(GetPosts())
 
 #print wp.call(GetUserInfo())

+ 4 - 2
test-wp2.py

@@ -10,6 +10,9 @@ from wordpress_xmlrpc import Client
 from wordpress_xmlrpc import WordPressPost, WordPressComment
 from wordpress_xmlrpc.methods.posts import GetPost
 
+from config import *
+
+
 
 # Access WP post
 # How to detector if it is available???
@@ -17,8 +20,7 @@ from wordpress_xmlrpc.methods.posts import GetPost
 
 # Use Wordpress account - not the mysql credentials
 # Todo: use scopus later !!!
-wp = Client('http://localhost/~kopmann/ufo2/xmlrpc.php', 'ufo', '$ipepdv$')
-
+wp = Client(wp_api_url, wp_user, wp_password)
 
 wpid = 1149
 if len(sys.argv) > 1:

+ 0 - 0
update.sh