Changed some depreciated functions & imports

This commit is contained in:
BuildTools 2021-04-22 17:42:24 +02:00
parent 730a352637
commit 7fdd7f3bd9
8 changed files with 27 additions and 92 deletions

View file

@ -471,13 +471,7 @@ class ConsoleText(QtWidgets.QTextEdit):
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor)) self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
# This is almost certainly no longer necessary.
textMenu = self.createStandardContextMenu() textMenu = self.createStandardContextMenu()
#~if self.textSelected:
#~ self.submitLogAction = QtGui.QAction("Submit to Pesterchum QDB", self)
#~ self.connect(self.submitLogAction, QtCore.SIGNAL('triggered()'),
#~ self, QtCore.SLOT('submitLog()'))
#~ textMenu.addAction(self.submitLogAction)
textMenu.exec_(event.globalPos()) textMenu.exec_(event.globalPos())

View file

@ -1,7 +1,6 @@
from string import Template from string import Template
import re import re
import platform import platform
import http.client, urllib.request, urllib.parse, urllib.error
from time import strftime from time import strftime
from copy import copy from copy import copy
from datetime import datetime, timedelta from datetime import datetime, timedelta
@ -515,51 +514,8 @@ class PesterText(QtWidgets.QTextEdit):
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
textMenu = self.createStandardContextMenu() textMenu = self.createStandardContextMenu()
#if self.textSelected:
# self.submitLogAction = QtGui.QAction("Submit to Pesterchum QDB", self)
# self.connect(self.submitLogAction, QtCore.SIGNAL('triggered()'),
# self, QtCore.SLOT('submitLog()'))
# textMenu.addAction(self.submitLogAction)
textMenu.exec_(event.globalPos()) textMenu.exec_(event.globalPos())
def submitLogTitle(self):
return "[%s -> %s]" % (self.parent().mainwindow.profile().handle,
self.parent().chum.handle)
@QtCore.pyqtSlot()
def submitLog(self):
mimedata = self.createMimeDataFromSelection()
htmldata = img2smiley(mimedata.data("text/html"))
textdoc = QtGui.QTextDocument()
textdoc.setHtml(htmldata)
logdata = "%s\n%s" % (self.submitLogTitle(), textdoc.toPlainText())
self.sending = QtWidgets.QDialog(self)
layout = QtWidgets.QVBoxLayout()
self.sending.sendinglabel = QtWidgets.QLabel("S3ND1NG...", self.sending)
cancelbutton = QtWidgets.QPushButton("OK", self.sending)
cancelbutton.clicked.connect(self.sending.close)
layout.addWidget(self.sending.sendinglabel)
layout.addWidget(cancelbutton)
self.sending.setLayout(layout)
self.sending.show()
params = urllib.parse.urlencode({'quote': logdata, 'do': "add"})
headers = {"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"}
try:
pass
hconn = http.client.HTTPConnection('qdb.pesterchum.net', 80,
timeout=15)
hconn.request("POST", "/index.php", params, headers)
response = hconn.getresponse()
if response.status == 200:
self.sending.sendinglabel.setText("SUCC3SS!")
else:
self.sending.sendinglabel.setText("F41L3D: %s %s" % (response.status, response.reason))
hconn.close()
except Exception as e:
self.sending.sendinglabel.setText("F41L3D: %s" % (e))
del self.sending
class PesterInput(QtWidgets.QLineEdit): class PesterInput(QtWidgets.QLineEdit):
stylesheet_path = "convo/input/style" stylesheet_path = "convo/input/style"
def __init__(self, theme, parent=None): def __init__(self, theme, parent=None):

View file

@ -212,15 +212,10 @@ class PesterLogViewer(QtWidgets.QDialog):
layout_search.addWidget(self.search) layout_search.addWidget(self.search)
layout_search.addWidget(self.find) layout_search.addWidget(self.find)
self.qdb = QtWidgets.QPushButton("Pesterchum QDB", self)
self.qdb.setFixedWidth(260)
self.qdb.clicked.connect(self.openQDB)
self.ok = QtWidgets.QPushButton("CLOSE", self) self.ok = QtWidgets.QPushButton("CLOSE", self)
self.ok.setFixedWidth(80) self.ok.setFixedWidth(80)
self.ok.clicked.connect(self.reject) self.ok.clicked.connect(self.reject)
layout_ok = QtWidgets.QHBoxLayout() layout_ok = QtWidgets.QHBoxLayout()
# Website is offline so there's no point.
#layout_ok.addWidget(self.qdb)
layout_ok.addWidget(self.ok) layout_ok.addWidget(self.ok)
layout_ok.setAlignment(self.ok, QtCore.Qt.AlignRight) layout_ok.setAlignment(self.ok, QtCore.Qt.AlignRight)
@ -243,10 +238,6 @@ class PesterLogViewer(QtWidgets.QDialog):
if len(self.tree.currentItem().text(0)) > len("September 2011"): if len(self.tree.currentItem().text(0)) > len("September 2011"):
self.loadLog(self.timeToFile(self.tree.currentItem().text(0))) self.loadLog(self.timeToFile(self.tree.currentItem().text(0)))
@QtCore.pyqtSlot()
def openQDB(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl("http://qdb.pesterchum.net/index.php?p=browse", QtCore.QUrl.TolerantMode))
def loadLog(self, fname): def loadLog(self, fname):
fp = codecs.open("%s/%s/%s/%s/%s" % (self.logpath, self.handle, self.chum, self.format, fname), encoding='utf-8', mode='r') fp = codecs.open("%s/%s/%s/%s/%s" % (self.logpath, self.handle, self.chum, self.format, fname), encoding='utf-8', mode='r')
self.textArea.clear() self.textArea.clear()
@ -299,11 +290,6 @@ class PesterLogText(PesterText):
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
textMenu = self.createStandardContextMenu() textMenu = self.createStandardContextMenu()
#if self.textSelected:
# self.submitLogAction = QtGui.QAction("Submit to Pesterchum QDB", self)
# self.connect(self.submitLogAction, QtCore.SIGNAL('triggered()'),
# self, QtCore.SLOT('submitLog()'))
# textMenu.addAction(self.submitLogAction)
a = textMenu.actions() a = textMenu.actions()
a[0].setText("Copy Plain Text") a[0].setText("Copy Plain Text")
a[0].setShortcut(self.tr("Ctrl+C")) a[0].setShortcut(self.tr("Ctrl+C"))

View file

@ -355,8 +355,6 @@ class MemoText(PesterText):
def changeTheme(self, theme): def changeTheme(self, theme):
self.initTheme(theme) self.initTheme(theme)
def submitLogTitle(self):
return "[%s]" % (self.parent().title())
class MemoInput(PesterInput): class MemoInput(PesterInput):
stylesheet_path = "memos/input/style" stylesheet_path = "memos/input/style"

View file

@ -18,15 +18,14 @@
import logging import logging
import socket import socket
import sys import sys
import re #import re
import string #import string
import time import time
import threading #import threading
import os import os
import traceback import traceback
import ssl
import ostools import ostools
import ssl
_datadir = ostools.getDataDir() _datadir = ostools.getDataDir()
from oyoyo.parse import * from oyoyo.parse import *

View file

@ -1,5 +1,9 @@
# pesterchum # Pesterchum :3c
import os, shutil, sys, getopt
import sys
import os
import shutil
import getopt
try: try:
QString = unicode QString = unicode
except NameError: except NameError:
@ -8,11 +12,8 @@ except NameError:
if os.path.dirname(sys.argv[0]): if os.path.dirname(sys.argv[0]):
os.chdir(os.path.dirname(sys.argv[0])) os.chdir(os.path.dirname(sys.argv[0]))
print("Usage: pesterchum.py [OPTIONS]") print("Usage: pesterchum.py [OPTIONS]")
print("Use -h/--help to see the available options.\n") print("Use -h/--help to see the available options.\n")
#print("sys.argv: " + str(sys.argv[1:]) + '\n')
# Help # Help
if ('--help' in sys.argv[1:]) or ('-h' in sys.argv[1:]): if ('--help' in sys.argv[1:]) or ('-h' in sys.argv[1:]):
print("Possible arguments:") print("Possible arguments:")
@ -26,9 +27,7 @@ if ('--help' in sys.argv[1:]) or ('-h' in sys.argv[1:]):
" --no-honk\n Disable honking.\n" " --no-honk\n Disable honking.\n"
print(help_arguments) print(help_arguments)
sys.exit() sys.exit()
import logging import logging
if ('--logging' in sys.argv[1:]) or ('-l' in sys.argv[1:]) & (False == ('--logging' in sys.argv[1:]) and ('-l' in sys.argv[1:])): if ('--logging' in sys.argv[1:]) or ('-l' in sys.argv[1:]) & (False == ('--logging' in sys.argv[1:]) and ('-l' in sys.argv[1:])):
try: try:
# If both are specified, this does not run. # If both are specified, this does not run.
@ -78,7 +77,7 @@ from datetime import *
import random import random
import re import re
from time import time from time import time
import threading, queue import queue#, threading
try: try:
import json import json
except: except:
@ -89,7 +88,6 @@ except ImportError:
# Fall back on the old location - just in case # Fall back on the old location - just in case
#logging.warning("Couldn't load attrdict from new loc; falling back") #logging.warning("Couldn't load attrdict from new loc; falling back")
from pnc.dep.attrdict import AttrDict from pnc.dep.attrdict import AttrDict
try: try:
import console import console
except ImportError: except ImportError:

View file

@ -24,17 +24,21 @@ includefiles = ["quirks",
"PCskins.png", "PCskins.png",
"Pesterchum.png"] "Pesterchum.png"]
build_exe_options = { build_exe_options = {
"includes": ["PyQt5", "includes": [""],
"pygame", ## "includes": ["PyQt5.QtCore",
"feedparser", ## "PyQt5.QtGui",
"magic", ## "PyQt5.QtMultimedia",
"ostools", ## "PyQt5.QtWidgets",
"requests", ## "pygame",
"urllib", ## "feedparser",
"pytwmn", ## "magic",
"re", ## "ostools",
"oyoyo", ## "requests",
"ssl"], ## "urllib",
## "pytwmn",
## "re",
## "oyoyo",
## "ssl"],
"excludes": ["collections.sys", "excludes": ["collections.sys",
"collections._sre", "collections._sre",
"collections._json", "collections._json",

View file

@ -1,5 +1,5 @@
import inspect import inspect
import threading #import threading
import time, os import time, os
import ostools import ostools
import logging import logging