Пример #1
0
    def send(self):
        """
        Send entered text as email to me via SMTP.
        """
        if str(self.body.toPlainText()) == "" or \
           str(self.body.toPlainText()).isspace() or \
           str(self.subject.text()) == "" or \
           str(self.subject.text()).isspace():
            popup("Please enter a message and subject.", "Critical")
            return
        msg = MIMEMultipart()
        body = MIMEText(
            str(self.body.toPlainText() + "\n\nSent by " + self.semT.text()))
        msg.attach(body)
        msg['From'] = str(self.semT.text())
        msg['To'] = "*****@*****.**"
        msg['Subject'] = str(self.subject.text())
        if self.addFiles.isChecked():
            print("Adding files")
            fileNames = glob(json_reader.buildPath("data/*.json")) + \
                        glob(json_reader.buildPath("data/pers/*.json")) + \
                        glob(json_reader.buildPath("data/chars/*.json"))
            print(fileNames)
            for file in fileNames:
                part = MIMEBase('application', "octet-stream")
                part.set_payload(open(file, "rb").read())
                part.add_header(
                    'Content-Disposition',
                    'attachment; filename="%s"' % file[file.rfind("/"):])
                msg.attach(part)

        serv = smtplib.SMTP("smtp.live.com", 587)
        serv.set_debuglevel(1)
        serv.ehlo()
        serv.starttls()
        serv.ehlo()
        serv.login("*****@*****.**", 'PersonaX')
        try:
            serv.sendmail(msg['From'], msg['To'], msg.as_string())
            print("Message sent successfully")
            popup("Email was sent! Thank you!", "Information")
            serv.quit()
            return
        except smtplib.SMTPSenderRefused:
            popup(
                "You must provide your email address so that we may contact you if needed.\n\nYour email "
                "address will not be shared with any third parties.",
                "Critical")
            serv.quit()
            return
        except Exception as e:  #pylint: disable=broad-except
            print(e)
            popup("Email failed to send, but not sure why...", "Critical")
Пример #2
0
    def importF(self):
        """
        Import a file or set of files from disk into Story-Creator controlled directories.

        :raises AssertionError: with an object attempting to being loaded if the object cannot be loaded as a
                 Social Link, Character or Persona.
        """
        fileBrowser = QFileDialog()
        fileBrowser.setFileMode(QFileDialog.Directory)
        fileBrowser.setViewMode(QFileDialog.Detail)
        fileBrowser.setOption(QFileDialog.ShowDirsOnly, True)
        if fileBrowser.exec_():
            paths = fileBrowser.selectedFiles()
        else:
            print("Cancelled")
            return
        print("Copying data from " + str(paths[0]))
        files = os.listdir(str(paths[0]))
        print(files)
        for file in files:
            if file.endswith(".json"):
                print("Copying valid file " + file)
                if "_link" in file:
                    if self.checkOverwrite(file):
                        copy(os.path.join(str(paths[0]), file),
                             json_reader.buildPath("data"))
                else:
                    try:  # Ugly AF
                        # TODO omgf this is more than ugly AF
                        characterL = json_reader.readOne(
                            file[:len(file) - 5], 'chars')
                        assert "name" in characterL and "important" in characterL
                        if self.checkOverwrite(file, 'chars'):
                            copy(os.path.join(str(paths[0]), file),
                                 json_reader.buildPath("data/chars"))
                    except AssertionError:
                        print("Not a Character")
                        try:
                            personaL = json_reader.readOne(
                                file[:len(file) - 5], 'pers')
                            assert "name" in personaL and "arcana" in personaL
                            if self.checkOverwrite(file, 'pers'):
                                copy(os.path.join(str(paths[0]), file),
                                     json_reader.buildPath("data/pers"))
                        except AssertionError:
                            print("Not a Persona")
                            raise AssertionError(personaL)
        print("Successfully copied files")
        popup("Files imported successfully!", "Information")
Пример #3
0
 def export(self):
     """
     Export the story-creator data files to a user-selected locaion.
     """
     fileBrowser = QFileDialog()
     fileBrowser.setFileMode(QFileDialog.Directory)
     fileBrowser.setViewMode(QFileDialog.Detail)
     fileBrowser.setOption(QFileDialog.ShowDirsOnly, True)
     if fileBrowser.exec_():
         paths = fileBrowser.selectedFiles()
     else:
         print("Cancelled")
         return
     print("Copying data to " + str(paths[0]) + "/exportdata")
     try:
         copytree(json_reader.buildPath("data"),
                  str(paths[0]) + "/exportdata")
     except OSError as e:
         print(e)
         popup(
             "Error in copying files. There is a file in the selected directory that has the same name "
             "as a Story Creator file.\n\nFiles are copied to " +
             str(paths[0]) + "/exportdata" + ". Please "
             "ensure this directory does not already exist.", "Critical")
         return
     print("Successfully copied files")
     popup("Files exported successfully!", "Information")
Пример #4
0
    def checkOverwrite(self, filepath, ctype=''):
        """
        Confirm with user if file should be overwritten.

        :param str filepath: path to file that could be overwritten
        :param str ctype: chars or pers if the file represents either type
        """
        if ctype:
            ctype = ctype + "/"
        if os.path.exists(os.path.join(json_reader.buildPath("data"),
                                       filepath)):
            if popup(
                    "File " + filepath[:len(filepath) - 5] +
                    " already exists. Overwrite?", "Warning"):
                os.remove(
                    json_reader.buildPath("data/%s%s" % (ctype, filepath)))
Пример #5
0
    def initUI(self):
        self.parent.setWindowTitle("1972 Sports Illustrated Football")

        self.grid = QGridLayout()
        self.setLayout(self.grid)

        imageLabel = QLabel(self)
        logo = QPixmap(json_reader.buildPath("homescreen.png"))
        imageLabel.setPixmap(logo)
        self.grid.addWidget(imageLabel, 0, 0)
Пример #6
0
 def showText(self):
     """
     Show the arcana's descriptive text upon selection.
     """
     temp = [self.arcSel.itemText(i) for i in range(self.arcSel.count())]
     if "Select Arcana" in temp:
         self.arcSel.removeItem(temp.index("Select Arcana"))
     self.text.setText(
         json_reader.readArcDesc(str(self.arcSel.currentText())))
     self.card.setPixmap(
         QPixmap(
             json_reader.buildPath("int/cards/" +
                                   str(self.arcSel.currentText()) +
                                   ".png")))
     self.destroyContext()
Пример #7
0
 def save(self):
     """
     Validate all info and save to file on disk.
     """
     if os.path.exists(json_reader.buildPath("data/pers/"+self.nameT.text()+".json")):
         if not popup("Override existing Persona "+self.nameT.text()+"?", "Question"):
             return
     print("Saving")
     spellDeck = []
     for combobox in self.iSpellOs:
         spellDeck.append(combobox.currentText())
     stats = [self.strT.text(), self.magT.text(), self.endT.text(), self.agiT.text(), self.luckT.text()]
     res = [self.slashO.currentText(), self.strikeO.currentText(), self.pierceO.currentText(),
            self.fireO.currentText(), self.iceO.currentText(), self.elecO.currentText(),
            self.windO.currentText(), self.lightO.currentText(), self.darkO.currentText()]
     try:
         (int)(self.levelT.text())
         (int)(self.strT.text())
         (int)(self.magT.text())
         (int)(self.endT.text())
         (int)(self.agiT.text())
         (int)(self.luckT.text())
     except ValueError:
         popup("There is a number entry that isn't valid.\nEntries requiring numbers are:\nLEVEL\nSTR"
               "\nMAG\nEND\nAGI\nLUCK", "Critical")
         print("Not Saved")
         return
     if not (self.nameT.text() and not self.nameT.text().isspace()):
         popup("No name entered for your Persona. Name is a required field.", "Critical")
         print("No Name, not saved")
         return
     toWrite = Persona(
         self.nameT.text(),
         self.arcO.currentText(),
         self.levelT.text(),
         self.textT.toPlainText(),
         spellDeck,
         self.lsdic,
         stats,
         res,
         [self.listEL1.currentText(), self.listEL2.currentText()]
     )
     json_reader.writeOne(toWrite, 'pers')
     temp = self.nameT.text()
     if (temp not in [self.listP.item(i).text() for i in range(self.listP.count())]):
         self.listP.addItem(temp)
     self.loadPer(temp)
     print("Saved Persona")
Пример #8
0
    def initUI(self):
        """
        Initialize the UI of this view.
        Does a lot of stuff.
        """
        self.mainframe.setWindowTitle("Story Creator")

        self.grid = QGridLayout()
        self.setLayout(self.grid)

        imageLabel = QLabel(self)
        logo = QPixmap(json_reader.buildPath("creator_logo.png"))
        imageLabel.setPixmap(logo)
        self.grid.addWidget(imageLabel, 0, 0)

        intframe = QWidget()
        self.grid.addWidget(intframe, 0, 1)

        bGrid = QGridLayout()
        intframe.setLayout(bGrid)

        createSL = QPushButton(intframe, text="Create Social Link")
        createSL.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        createSL.clicked.connect(self.actionS)
        bGrid.addWidget(createSL, 0, 0)

        createPersona = QPushButton(intframe, text="Create Persona")
        createPersona.setSizePolicy(QSizePolicy.Preferred,
                                    QSizePolicy.Expanding)
        createPersona.clicked.connect(self.actionP)
        bGrid.addWidget(createPersona, 1, 0)

        createChar = QPushButton(intframe, text="Create Character")
        createChar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        createChar.clicked.connect(self.actionC)
        bGrid.addWidget(createChar, 2, 0)

        support = QPushButton(intframe, text="Support/Contact")
        support.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        support.clicked.connect(self.actionE)
        bGrid.addWidget(support, 3, 0)

        quitbutt = QPushButton(intframe, text="Quit")
        quitbutt.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        quitbutt.clicked.connect(self.quit)
        bGrid.addWidget(quitbutt, 4, 0)
Пример #9
0
    def initUI(self):
        """
        Initializes the GUI.
        Does a lot of stuff.
        """
        self.mainframe.setWindowTitle("Social Link Creator")
        self.grid = QGridLayout()
        self.setLayout(self.grid)

        arcanaList = json_reader.data_list("arcanas")

        self.arcSel = QComboBox(self)
        self.arcSel.addItem("Select Arcana")
        self.arcSel.activated.connect(self.showText)
        self.arcSel.addItems(arcanaList)
        self.arcSel.setCurrentIndex(0)
        self.grid.addWidget(self.arcSel, 1, 1)

        select = QPushButton(self, text="Select")
        select.clicked.connect(self.context)
        self.grid.addWidget(select, 2, 1)

        info = QPushButton(self, text="Info")
        info.clicked.connect(self.infoF)
        self.grid.addWidget(info, 3, 1)

        back = QPushButton(self, text="Back")
        back.clicked.connect(self.back)
        self.grid.addWidget(back, 4, 1)

        self.card = QLabel(self)
        defaultCard = QPixmap(json_reader.buildPath("int/cards/card.png"))
        self.card.setPixmap(defaultCard)
        self.card.setAlignment(Qt.AlignHCenter)
        self.grid.addWidget(self.card, 0, 0)

        self.text = QLabel(self, text="")
        self.text.setFixedSize(400, 250)
        self.text.setWordWrap(True)
        self.text.setAlignment(Qt.AlignHCenter)
        self.grid.addWidget(self.text, 1, 0, 4, 1)
Пример #10
0
    def initUI(self):
        """
        _
        """
        self.grid = QGridLayout()
        self.setLayout(self.grid)

        imageLabel = QLabel(self)
        logo = QPixmap(json_reader.buildPath("gameheader.png"))
        imageLabel.setPixmap(logo)
        self.grid.addWidget(imageLabel, 0, 0, 2, 4)

        self.score1 = QLabel("0")
        self.score2 = QLabel("0")
        self.timer = QLabel("00:00")
        self.down = QLabel("1st")
        self.quarter = QLabel("1")

        self.grid.addWidget(self.score1, 0, 0, 2, 1)
        self.grid.addWidget(self.score2, 0, 3, 2, 1)
        self.grid.addWidget(self.timer, 0, 1, 1, 2)
        self.grid.addWidget(self.down, 1, 1)
        self.grid.addWidget(self.quarter, 1, 2)
Пример #11
0
"""
Main entry module for the application.
"""
#pylint: disable=no-name-in-module
import sys
from PySide2.QtWidgets import QApplication
from PySide2.QtGui import QIcon
from libs import json_reader
from qtmainframe import MainFrame

APP = QApplication(sys.argv)
APP.setWindowIcon(QIcon(json_reader.buildPath('icon.gif')))
MAINF = MainFrame(APP)
sys.exit(APP.exec_())