forked from importers/git-importer
execute user import
This commit is contained in:
parent
5ed847de8b
commit
10cd7e4e38
@ -159,7 +159,6 @@ class DB:
|
|||||||
CREATE TABLE users (
|
CREATE TABLE users (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
userid VARCHAR(255) NOT NULL,
|
userid VARCHAR(255) NOT NULL,
|
||||||
login VARCHAR(255) NOT NULL,
|
|
||||||
email VARCHAR(255) NOT NULL,
|
email VARCHAR(255) NOT NULL,
|
||||||
realname VARCHAR(255) NOT NULL
|
realname VARCHAR(255) NOT NULL
|
||||||
)
|
)
|
||||||
|
@ -10,6 +10,7 @@ from lib.obs import OBS
|
|||||||
from lib.obs_revision import OBSRevision
|
from lib.obs_revision import OBSRevision
|
||||||
from lib.proxy_sha256 import ProxySHA256, md5, sha256
|
from lib.proxy_sha256 import ProxySHA256, md5, sha256
|
||||||
from lib.request import Request
|
from lib.request import Request
|
||||||
|
from lib.users import Users
|
||||||
|
|
||||||
|
|
||||||
def _files_hash(hash_alg, dirpath):
|
def _files_hash(hash_alg, dirpath):
|
||||||
@ -173,6 +174,10 @@ class Importer:
|
|||||||
else:
|
else:
|
||||||
rev.set_broken(db)
|
rev.set_broken(db)
|
||||||
|
|
||||||
|
fake_accounts = ["unknown","buildservice-autocommit", "autobuild", "_service"]
|
||||||
|
if Users.user_lookup(db, rev.userid) is None and rev.userid not in fake_accounts:
|
||||||
|
self.obs.users(rev.userid).import_into_db(db)
|
||||||
|
|
||||||
for number in DBRevision.requests_to_fetch(db, project, self.package):
|
for number in DBRevision.requests_to_fetch(db, project, self.package):
|
||||||
self.obs.request(number).import_into_db(db)
|
self.obs.request(number).import_into_db(db)
|
||||||
|
|
||||||
|
14
lib/users.py
14
lib/users.py
@ -1,14 +1,13 @@
|
|||||||
class Users:
|
class Users:
|
||||||
def parse(self, xml, userid):
|
def parse(self, xml, userid):
|
||||||
self.userid = userid
|
self.userid = userid
|
||||||
self.login = xml.get("login")
|
self.realname = xml.find("realname").text
|
||||||
self.realname = xml.find("login").get("realname")
|
self.email = xml.find("email").text
|
||||||
self.email = xml.find("login").get("email")
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"User {self.userid} {self.login}: {self.realname} {self.email}"
|
return f"User {self.userid}: {self.realname} {self.email}"
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"[{self.__str__()}]"
|
return f"[{self.__str__()}]"
|
||||||
@ -16,18 +15,17 @@ class Users:
|
|||||||
def import_into_db(self, db):
|
def import_into_db(self, db):
|
||||||
cur = db.cursor()
|
cur = db.cursor()
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"""INSERT INTO users (userid, login, realname, email)
|
"""INSERT INTO users (userid, realname, email)
|
||||||
VALUES (%s,%s,%s,%s) RETURNING id""",
|
VALUES (%s,%s,%s) RETURNING id""",
|
||||||
(
|
(
|
||||||
self.userid,
|
self.userid,
|
||||||
self.login,
|
|
||||||
self.realname,
|
self.realname,
|
||||||
self.email,
|
self.email,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
cur.close()
|
cur.close()
|
||||||
|
|
||||||
def user_lookup(self, db, userid):
|
def user_lookup(db, userid):
|
||||||
cur= db.cursor()
|
cur= db.cursor()
|
||||||
cur.execute("SELECT * FROM users where userid=%s", (userid,))
|
cur.execute("SELECT * FROM users where userid=%s", (userid,))
|
||||||
row = cur.fetchone()
|
row = cur.fetchone()
|
||||||
|
Loading…
Reference in New Issue
Block a user