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))
def contextMenuEvent(self, event):
# This is almost certainly no longer necessary.
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())

View file

@ -1,7 +1,6 @@
from string import Template
import re
import platform
import http.client, urllib.request, urllib.parse, urllib.error
from time import strftime
from copy import copy
from datetime import datetime, timedelta
@ -515,51 +514,8 @@ class PesterText(QtWidgets.QTextEdit):
def contextMenuEvent(self, event):
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())
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):
stylesheet_path = "convo/input/style"
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.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.setFixedWidth(80)
self.ok.clicked.connect(self.reject)
layout_ok = QtWidgets.QHBoxLayout()
# Website is offline so there's no point.
#layout_ok.addWidget(self.qdb)
layout_ok.addWidget(self.ok)
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"):
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):
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()
@ -299,11 +290,6 @@ class PesterLogText(PesterText):
def contextMenuEvent(self, event):
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[0].setText("Copy Plain Text")
a[0].setShortcut(self.tr("Ctrl+C"))

View file

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

View file

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

View file

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

View file

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

View file

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