def _temp_dir(path): path = app.path(path) d = os.path.join( app.temp_dir, urllib.quote(path.replace('\\', '/')).replace( '/', '%2F').replace('%', '.')) app.sure_mkdir(d) return d
def audio_slice(r): path = app.path(r.form['file']) start = float(r.form['start']) duration = float(r.form['duration']) output_dir = _temp_dir(r.form['output_dir']) try: return madmagia.audio_slice.slice(path, start, start + duration, output_dir) except StandardError, e: logger.exception(e) return []
def gen_frame(r): epnum = r.form['epnum'] time = float(r.form['time']) try: return madmagia.video_slice.save_frame_to( time, app.path(r.form['source_path']), os.path.join(_temp_dir(r.form['output_path']), '%s_%f.png' % (epnum, time)), (480, 270)) except madmagia.shell.ShellError: return ''
from app import path from views import * urls = ({ path('/show_load/', show_load_file), path('/upload_file/', upload_file), path('/load_file/<filename>/', download_file), })
def setupUi(self): self.win.setWindowTitle(f"Tassomai Automation v{__version__}") self.win.setWindowIcon(QIcon(path('images', 'logo.png'))) self.win.resize(665, 580) self.centralwidget = QWidget(self.win) self.formLayout = QFormLayout(self.centralwidget) self.formLayout.setContentsMargins(5, 0, 5, -1) self.topFrame = QFrame(self.centralwidget) sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.topFrame.sizePolicy().hasHeightForWidth()) self.topFrame.setSizePolicy(sizePolicy) self.topFrame.setAutoFillBackground(True) self.topFrame.setFrameShape(QFrame.StyledPanel) self.topFrame.setFrameShadow(QFrame.Raised) self.gridLayout = QGridLayout(self.topFrame) self.tassomaiImage = QLabel(self.topFrame) sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.tassomaiImage.sizePolicy().hasHeightForWidth()) self.tassomaiImage.setSizePolicy(sizePolicy) self.tassomaiImage.setPixmap(QPixmap(path('images', 'banner.png'))) self.gridLayout.addWidget(self.tassomaiImage, 0, 0, 1, 1) self.formLayout.setWidget(0, QFormLayout.SpanningRole, self.topFrame) self.tab = QTabWidget(self.centralwidget) self.main_tab = QWidget() self.automation_tab = QWidget() self.gridLayout_4 = QGridLayout(self.main_tab) self.gridLayout_4.setContentsMargins(0, 0, 0, 0) self.main_frame = QFrame(self.main_tab) self.main_frame.setAutoFillBackground(True) self.main_frame.setFrameShape(QFrame.StyledPanel) self.main_frame.setFrameShadow(QFrame.Raised) self.gridLayout_2 = QGridLayout(self.main_frame) self.gridLayout_2.setContentsMargins(5, 6, 2, -1) self.gridLayout_2.setVerticalSpacing(10) self.gridLayout_5 = QGridLayout(self.automation_tab) self.gridLayout_5.setContentsMargins(0, 0, 0, 0) self.automation_frame = QFrame(self.automation_tab) self.automation_frame.setAutoFillBackground(True) self.automation_frame.setFrameShape(QFrame.StyledPanel) self.automation_frame.setFrameShadow(QFrame.Raised) self.delayLayout = QHBoxLayout() self.delayLayout.setContentsMargins(0, 0, 0, 0) self.delayLayout.setSpacing(3) self.delay = QCheckBox(self.main_frame) font = QFont() font.setPointSize(10) self.delay.setFont(font) self.delayLayout.addWidget(self.delay) self.amountOfDelay = QDoubleSpinBox(self.main_frame) self.amountOfDelay.setMinimumWidth(70) self.amountOfDelay.setMaximum(25.00) self.delayLayout.addWidget(self.amountOfDelay) self.label03 = QLabel(self.main_frame) self.label03.setSizePolicy(sizePolicy) self.label03.setFont(font) self.delayLayout.addWidget(self.label03) self.amountOfDelay2 = QDoubleSpinBox(self.main_frame) self.amountOfDelay2.setMinimumWidth(70) self.amountOfDelay2.setMaximum(25.00) self.delayLayout.addWidget(self.amountOfDelay2) self.label3 = QLabel(self.main_frame) self.label3.setSizePolicy(sizePolicy) self.label3.setFont(font) self.delayLayout.addWidget(self.label3) self.whenDelay = QComboBox(self.main_frame) self.whenDelay.addItem("question") self.whenDelay.addItem("quiz") self.whenDelay.setMaximumWidth(100) self.delayLayout.addWidget(self.whenDelay) self.verticalSpacer1 = QSpacerItem(20, 40, QSizePolicy.Expanding, QSizePolicy.Expanding) self.delayLayout.addItem(self.verticalSpacer1) self.gridLayout_2.addLayout(self.delayLayout, 2, 0, 1, 1) self.randomnessLayout = QHBoxLayout() self.randomnessLayout.setContentsMargins(0, 0, 0, 0) self.randomnessLayout.setSpacing(3) self.randomness = QCheckBox(self.main_frame) self.randomness.setFont(font) self.randomness.setMaximumWidth(338) self.randomnessLayout.addWidget(self.randomness) self.randomnessAmount = QSpinBox(self.main_frame) self.randomnessAmount.setMinimumWidth(70) self.randomnessAmount.setMaximum(600) self.randomnessLayout.addWidget(self.randomnessAmount) self.label4 = QLabel(self.main_frame) self.label4.setSizePolicy(sizePolicy) self.label4.setFont(font) self.randomnessLayout.addWidget(self.label4) self.gridLayout_2.addLayout(self.randomnessLayout, 3, 0, 1, 1) self.dailyGoal = QCheckBox(self.main_frame) font = QFont() font.setPointSize(10) self.dailyGoal.setFont(font) self.gridLayout_2.addWidget(self.dailyGoal, 4, 0, 1, 1) self.bonusGoal = QCheckBox(self.main_frame) self.bonusGoal.setFont(font) self.gridLayout_2.addWidget(self.bonusGoal, 5, 0, 1, 1) self.horizontalLayout = QHBoxLayout() self.label1 = QLabel(self.main_frame) sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label1.sizePolicy().hasHeightForWidth()) self.label1.setSizePolicy(sizePolicy) font = QFont() font.setPointSize(10) self.label1.setFont(font) self.horizontalLayout.addWidget(self.label1) self.maxQuizes = QSpinBox(self.main_frame) self.maxQuizes.setMinimum(1) self.maxQuizes.setMaximum(1000000) self.maxQuizes.setProperty("value", 1000) self.horizontalLayout.addWidget(self.maxQuizes) self.label2 = QLabel(self.main_frame) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label2.sizePolicy().hasHeightForWidth()) self.label2.setSizePolicy(sizePolicy) font = QFont() font.setPointSize(10) self.label2.setFont(font) self.horizontalLayout.addWidget(self.label2) self.gridLayout_2.addLayout(self.horizontalLayout, 1, 0, 1, 1) self.userBox = QGroupBox(self.main_frame) font = QFont() font.setPointSize(9) font.setBold(False) font.setWeight(50) self.userBox.setFont(font) self.gridLayout_3 = QGridLayout(self.userBox) self.emailTassomaiLabel = QLabel(self.userBox) self.gridLayout_3.addWidget(self.emailTassomaiLabel, 0, 0, 1, 1) self.emailTassomai = QLineEdit(self.userBox) self.gridLayout_3.addWidget(self.emailTassomai, 0, 1, 1, 1) self.passwordTassomaiLabel = QLabel(self.userBox) self.gridLayout_3.addWidget(self.passwordTassomaiLabel, 1, 0, 1, 1) self.passwordTassomai = QLineEdit(self.userBox) self.passwordTassomai.setEchoMode(QLineEdit.Password) self.gridLayout_3.addWidget(self.passwordTassomai, 1, 1, 1, 1) self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.gridLayout_3.addItem(self.verticalSpacer, 2, 0, 1, 1) self.gridLayout_4.addWidget(self.main_frame, 0, 0, 1, 1) self.gridLayout_5.addWidget(self.automation_frame, 0, 0, 1, 1) self.tab.addTab(self.main_tab, "") self.tab.addTab(self.automation_tab, "") self.formLayout.setWidget(1, QFormLayout.SpanningRole, self.tab) self.gridLayout_2.addWidget(self.userBox, 0, 0, 1, 1) self.buttonsLayout = QHBoxLayout() self.bottom_frame = QFrame(self.centralwidget) self.bottom_frame.setFrameShape(QFrame.StyledPanel) self.bottom_frame.setFrameShadow(QFrame.Raised) self.gridLayout_7 = QGridLayout(self.bottom_frame) self.gridLayout_7.setContentsMargins(0, 0, 0, 0) self.startButton = QPushButton(self.bottom_frame) self.buttonsLayout.addWidget(self.startButton) self.stopButton = QPushButton(self.bottom_frame) self.buttonsLayout.addWidget(self.stopButton) self.gridLayout_7.addLayout(self.buttonsLayout, 0, 0, 1, 1) self.output = QTextEdit(self.bottom_frame) self.gridLayout_7.addWidget(self.output, 1, 0, 1, 1) self.formLayout.setWidget(2, QFormLayout.SpanningRole, self.bottom_frame) self.win.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(self.win) self.menubar.setGeometry(QRect(0, 0, 665, 21)) self.tools_menu = QMenu(self.menubar) self.uninstall_option = QAction() self.tools_menu.addAction(self.uninstall_option) self.menubar.addAction(self.tools_menu.menuAction()) self.win.setMenuBar(self.menubar) self.createTable() self.retranslateUi() self.tab.setCurrentIndex(0) self.tab.currentChanged['int'].connect(lambda k: self.bottom_frame.hide() if k != 0 else self.bottom_frame.show()) QMetaObject.connectSlotsByName(self.win)
from flask import Flask, url_for, render_template, request from views import * from app import path app = Flask(__name__) # 该函数是路由装饰器@app.route()的底层实现方式,该方法可以实现指定 # 函数与对应路由的绑定操作 urls = ([ path('/login/', show_login), path('/regist/', show_regist), path('/regist/account_regist/', account_regist), path('/account_login/', account_login), ])
def listen_audio(): return flask.send_file(app.path(flask.request.args['path']))
def media_len(r): try: return madmagia.audio_slice.audio_len(app.path(r.args['path'])) except StandardError, e: logger.exception(e) return -1
def view_video(): return flask.send_file(app.path(flask.request.args['path']))