mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Additional lines of code
This commit is contained in:
@@ -495,6 +495,20 @@ async def play(ctx, zamawial=None, arg=None):
|
|||||||
await ctx.send(result)
|
await ctx.send(result)
|
||||||
|
|
||||||
|
|
||||||
|
async def archive_channel(channel_no):
|
||||||
|
channel = client.get_channel(channel_no)
|
||||||
|
messages = [message async for message in channel.history(limit=None)]
|
||||||
|
path_newfile = (
|
||||||
|
f"{LOGSTORE}channeldump_{channel_no}_{datetime.now()}.json"
|
||||||
|
)
|
||||||
|
new_data = []
|
||||||
|
for message in messages:
|
||||||
|
pass
|
||||||
|
with open(path_newfile, "x", encoding=ENCODING) as new_file:
|
||||||
|
new_file.seek(0)
|
||||||
|
json.dump(new_data, new_file, indent=4)
|
||||||
|
|
||||||
|
|
||||||
async def check():
|
async def check():
|
||||||
"""Funkcja sprawdzająca czy grać następny kawałek."""
|
"""Funkcja sprawdzająca czy grać następny kawałek."""
|
||||||
last_spontaneous_call = datetime.now()
|
last_spontaneous_call = datetime.now()
|
||||||
|
|||||||
+1707
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,188 @@
|
|||||||
|
import re
|
||||||
|
import time
|
||||||
|
output_size = 0
|
||||||
|
preface = True
|
||||||
|
header_no = 0
|
||||||
|
output_no = 0
|
||||||
|
header = False
|
||||||
|
body = False
|
||||||
|
footer = False
|
||||||
|
file_limit = 500000*1024
|
||||||
|
|
||||||
|
|
||||||
|
def smart_write(line, file):
|
||||||
|
encoded_bytes = line.encode("utf-8")
|
||||||
|
size_in_bytes = len(encoded_bytes)
|
||||||
|
op_file.write(line)
|
||||||
|
return size_in_bytes
|
||||||
|
|
||||||
|
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/scimag_2020-05-30.sql", encoding="utf-8"
|
||||||
|
) as infile:
|
||||||
|
for line in infile:
|
||||||
|
line.replace("`", "'")
|
||||||
|
|
||||||
|
if re.compile("INSERT").search(line):
|
||||||
|
if preface:
|
||||||
|
preface = False
|
||||||
|
body = True
|
||||||
|
op_file_name = "scimag_chunk_{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
|
||||||
|
elif header:
|
||||||
|
header = False
|
||||||
|
body = True
|
||||||
|
op_file_name = "scimag_chunk_{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
|
||||||
|
elif footer:
|
||||||
|
print("ERROR: Insert after footer (without header)")
|
||||||
|
elif body:
|
||||||
|
if output_size > file_limit:
|
||||||
|
output_no += 1
|
||||||
|
output_size = 0
|
||||||
|
op_file_name = "scimag_chunk_{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
else:
|
||||||
|
print("ERROR: Insert with no state")
|
||||||
|
elif re.compile("UNLOCK").search(line):
|
||||||
|
if preface:
|
||||||
|
print("ERROR: UNLOCK in preface state")
|
||||||
|
|
||||||
|
elif header:
|
||||||
|
header = False
|
||||||
|
footer = True
|
||||||
|
op_file_name = "scimag_chunk_footer{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
elif footer:
|
||||||
|
op_file_name = "scimag_chunk_footer{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
elif body:
|
||||||
|
body = False
|
||||||
|
footer = True
|
||||||
|
op_file_name = "scimag_chunk_footer{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("ERROR: Unlock in unknown state")
|
||||||
|
|
||||||
|
elif re.compile("LOCK").search(line):
|
||||||
|
header_no += 1
|
||||||
|
if preface:
|
||||||
|
preface = False
|
||||||
|
header = True
|
||||||
|
op_file_name = "scimag_chunk_header_{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
|
||||||
|
elif header:
|
||||||
|
op_file_name = "scimag_chunk_header_{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
|
||||||
|
elif footer:
|
||||||
|
footer = False
|
||||||
|
header = True
|
||||||
|
op_file_name = "scimag_chunk_header_{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
elif body:
|
||||||
|
body = False
|
||||||
|
header = True
|
||||||
|
op_file_name = "scimag_chunk_header_{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
else:
|
||||||
|
print("ERROR: Lock in unknown state")
|
||||||
|
|
||||||
|
else:
|
||||||
|
if preface:
|
||||||
|
op_file_name = "scimag_chunk_{}_preface.sql".format(
|
||||||
|
header_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
op_file.write(line)
|
||||||
|
elif header:
|
||||||
|
op_file_name = "scimag_chunk_header_{}_{}.sql".format(
|
||||||
|
header_no, output_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
output_size += smart_write(line, op_file)
|
||||||
|
elif body:
|
||||||
|
print("ERROR: Other command in locked state")
|
||||||
|
elif footer:
|
||||||
|
header_no += 1
|
||||||
|
op_file_name = "scimag_chunk_{}_preface.sql".format(
|
||||||
|
header_no)
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(op_file_name),
|
||||||
|
"a",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as op_file:
|
||||||
|
op_file.write(line)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("ERROR: Other command in unknown state")
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import netrc
|
||||||
|
|
||||||
|
import mysql.connector
|
||||||
|
|
||||||
|
NETRC_FILE = "/home/mtuszowski/.netrc"
|
||||||
|
|
||||||
|
netrc_mod = netrc.netrc(NETRC_FILE)
|
||||||
|
REMOTE_HOST_NAME = "sql_localhost"
|
||||||
|
authTokens = netrc_mod.authenticators(REMOTE_HOST_NAME)
|
||||||
|
|
||||||
|
mydb = mysql.connector.connect(
|
||||||
|
host="localhost", user="root", password="root", database="scihubdois"
|
||||||
|
)
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
mycursor.execute("SELECT * FROM scimag")
|
||||||
|
for x in mycursor:
|
||||||
|
print(x)
|
||||||
|
|
||||||
|
exit()
|
||||||
|
file_list = ""
|
||||||
|
for file in file_list:
|
||||||
|
|
||||||
|
with open(
|
||||||
|
"/mnt/n/scimag_2020-05-30.sql/{}".format(file), encoding="utf-8"
|
||||||
|
) as infile:
|
||||||
|
pass
|
||||||
|
result = mycursor.execute("SHOW databases")
|
||||||
|
# trunk-ignore(mypy/union-attr)
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import netrc
|
||||||
|
|
||||||
|
import psycopg2
|
||||||
|
|
||||||
|
NETRC_FILE = ""
|
||||||
|
NETRC_FILE = "/home/mtuszowski/.netrc"
|
||||||
|
# NETRC_FILE = "/home/pi/.netrc"
|
||||||
|
# NETRC_FILE = "C:\\Users\\mtusz\\.netrc"
|
||||||
|
|
||||||
|
netrc_mod = netrc.netrc(NETRC_FILE)
|
||||||
|
REMOTE_HOST_NAME = "sql_localhost"
|
||||||
|
authTokens = netrc_mod.authenticators(REMOTE_HOST_NAME)
|
||||||
|
|
||||||
|
# Connect to your postgres DB
|
||||||
|
conn = psycopg2.connect(
|
||||||
|
database="scihubdois",
|
||||||
|
host="localhost",
|
||||||
|
# trunk-ignore(mypy/index)
|
||||||
|
user=authTokens[0],
|
||||||
|
# trunk-ignore(mypy/index)
|
||||||
|
password=authTokens[2],
|
||||||
|
port="5432",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Open a cursor to perform database operations
|
||||||
|
cur = conn.cursor()
|
||||||
|
|
||||||
|
# Execute a query
|
||||||
|
cur.execute("SELECT * FROM version()")
|
||||||
|
|
||||||
|
# Retrieve query results
|
||||||
|
records = cur.fetchall()
|
||||||
|
print(records)
|
||||||
Reference in New Issue
Block a user