Exemplo n.º 1
0
def potrace_exists(base_pathname):
    """
    potraceが呼び出せるか確認を行います。
    """

    list_potrace_pathname = [
        "potrace", os.path.join(base_pathname, "bin", "potrace")
    ]

    for rel_path in list_potrace_pathname:
        if sys.platform in ("win32", ):
            rel_path += ".exe"
        abs_path = os.path.abspath(rel_path)
        if os.path.exists(abs_path) is True:
            stdout_captured = io.TextIOBase()
            try:
                o_result = subprocess.run([abs_path, "-v"],
                                          check=True,
                                          stdout=subprocess.PIPE)
                if o_result.returncode == 0:
                    return abs_path
                else:
                    raise CExcPotraceNotExecutable(
                        "'{}' can not be executed.".format(abs_path))
            except PermissionError:
                raise CExcPotraceNotExecutable(
                    "'{}' can not be executed.".format(abs_path))

    raise CExcPotraceNotFound("Potrace is not found.")
Exemplo n.º 2
0
#NOTE: base class of all ctypes data types is non-public _CData

try:  # python 2.6
    import fractions
    import number
    import io
    from io import StringIO as TextIO
    # built-in functions (CH 2)
    a['ByteArrayType'] = bytearray([1])
    # numeric and mathematical types (CH 9)
    a['FractionType'] = fractions.Fraction()
    a['NumberType'] = numbers.Number()
    # generic operating system services (CH 15)
    a['IOBaseType'] = io.IOBase()
    a['RawIOBaseType'] = io.RawIOBase()
    a['TextIOBaseType'] = io.TextIOBase()
    a['BufferedIOBaseType'] = io.BufferedIOBase()
    a['UnicodeIOType'] = TextIO()  # the new StringIO
    a['LoggingAdapterType'] = logging.LoggingAdapter(_logger,
                                                     _dict)  # pickle ok
    if HAS_CTYPES:
        a['CBoolType'] = ctypes.c_bool(1)
        a['CLongDoubleType'] = ctypes.c_longdouble()
except ImportError:
    pass
try:  # python 2.7
    import argparse
    # data types (CH 8)
    a['OrderedDictType'] = collections.OrderedDict(_dict)
    a['CounterType'] = collections.Counter(_dict)
    if HAS_CTYPES:
Exemplo n.º 3
0
from proxypool.scheduler import Scheduler
import sys
import io

sys.stdout = io.TextIOBase(sys.stdout.buffer, encoding='utf-8')


def main():
    try:
        s = Scheduler()
        s.run()
    except:
        main()


if __name__ == '__main__':
    main()
Exemplo n.º 4
0
import os
#from PySide.QtCore import QRect, QMetaObject, QObject
#from PySide.QtGui  import (QApplication, QMainWindow, QWidget, 
#			QGridLayout, QTabWidget, QPlainTextEdit,
#			QMenuBar, QMenu, QStatusBar, QAction, 
#			QIcon, QFileDialog, QMessageBox, QFont)

from PySide import QtGui
from PySide import QtCore
from PySide.QtCore import *

from PySide.QtGui  import *

sys.path.append( '../stochastic/')

msgStream=io.TextIOBase()

from stochastic.imperfGen import *
class MiniLogger(object):
	def info(self,message):
		msgStream.write(time.strftime("%a %H:%M:%S:  ",time.localtime())+str(message)+'\n')
	def error(self,message):
		msgStream.write(time.strftime("%a %H:%M:%S: ERROR: ",time.localtime())+str(message)+'\n')
#
#class EmittingStream(QtCore.QObject):
#
#	textWritten = QtCore.pyqtSignal(str)
#
#	def write(self, text):
#		self.textWritten.emit(str(text))
#
Exemplo n.º 5
0
    def initGUI(self):
        ######################
        self.setWindowTitle('BKReport')
        self.setGeometry(300, 300, 1000, 600)

        ##########LAYOUT###########
        self.query_check = QRadioButton("Query", self)
        self.query_check.clicked.connect(self.SelectInput)
        self.query_edit = QLineEdit(self)
        self.info_check = QRadioButton("Info file", self)
        self.info_check.clicked.connect(self.SelectInput)
        self.info_check.setFixedWidth(100)
        self.info_path = QLabel("no file selected ...", self)
        self.info_path.setAlignment(Qt.AlignCenter)
        self.info_button = QPushButton("Select", self)
        self.info_button.setFixedWidth(100)
        self.info_button.clicked.connect(self.SelectInfoFile)
        self.info_button.setEnabled(False)
        self.test_check = QRadioButton("Test Query", self)
        self.test_check.clicked.connect(self.SelectInput)
        self.test_label = QLabel(BKReport.test_query, self)
        self.test_label.setAlignment(Qt.AlignCenter)
        input_layout = QGridLayout()
        input_layout.addWidget(self.query_check, 0, 0)
        input_layout.addWidget(self.query_edit, 0, 1, 1, 2)
        input_layout.addWidget(self.info_check, 1, 0)
        input_layout.addWidget(self.info_path, 1, 1)
        input_layout.addWidget(self.info_button, 1, 2)
        input_layout.addWidget(self.test_check, 2, 0)
        input_layout.addWidget(self.test_label, 2, 1)
        input_box = QGroupBox("Input Method", self)
        input_box.setLayout(input_layout)

        self.people_path = QLabel(self)
        self.people_path.setAlignment(Qt.AlignCenter)
        self.people_preview = QLabel(self)
        self.people_preview.setAlignment(Qt.AlignCenter)
        self.people_button = QPushButton("Select", self)
        self.people_button.setFixedWidth(100)
        self.people_button.clicked.connect(self.SelectPeopleFile)
        self.people_edit_button = QPushButton("View/Edit", self)
        self.people_edit_button.setFixedWidth(100)
        self.people_edit_button.clicked.connect(self.EditPeopleFile)
        people_layout = QGridLayout()
        people_layout.addWidget(self.people_path, 0, 0)
        people_layout.addWidget(self.people_button, 0, 1)
        people_layout.addWidget(self.people_preview, 1, 0)
        people_layout.addWidget(self.people_edit_button, 1, 1)
        people_box = QGroupBox("People File", self)
        people_box.setLayout(people_layout)

        self.format_path = QLabel(self)
        self.format_path.setAlignment(Qt.AlignCenter)
        self.format_preview = QLabel(self)
        self.format_preview.setAlignment(Qt.AlignCenter)
        self.format_button = QPushButton("Select", self)
        self.format_button.setFixedWidth(100)
        self.format_button.clicked.connect(self.SelectFormatFile)
        self.format_edit_button = QPushButton("View/Edit", self)
        self.format_edit_button.setFixedWidth(100)
        self.format_edit_button.clicked.connect(self.EditFormatFile)
        format_layout = QGridLayout()
        format_layout.addWidget(self.format_path, 0, 0)
        format_layout.addWidget(self.format_button, 0, 1)
        format_layout.addWidget(self.format_preview, 1, 0)
        format_layout.addWidget(self.format_edit_button, 1, 1)
        format_box = QGroupBox("Format File", self)
        format_box.setLayout(format_layout)

        self.date_check = QCheckBox("date", self)
        self.date_check.clicked.connect(self.SetDateFilter)
        self.date_start_label = QLabel("from", self)
        self.date_start_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.date_start = QDateEdit(self)
        self.date_start.setDisplayFormat("yyyy-MM-dd")
        self.date_end_label = QLabel("to", self)
        self.date_end_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.date_end = QDateEdit(self)
        self.date_end.setDisplayFormat("yyyy-MM-dd")
        filter_layout = QGridLayout()
        filter_layout.addWidget(self.date_check, 0, 0)
        filter_layout.addWidget(self.date_start_label, 0, 1)
        filter_layout.addWidget(self.date_start, 0, 2)
        filter_layout.addWidget(self.date_end_label, 0, 3)
        filter_layout.addWidget(self.date_end, 0, 4)
        filter_box = QGroupBox("Filter", self)
        filter_box.setLayout(filter_layout)

        self.output_check = QCheckBox("Auto", self)
        self.output_check.setFixedWidth(100)
        self.output_check.clicked.connect(self.SetAutoOutputDir)
        self.output_path = QLabel("No directory selected ...", self)
        self.output_path.setAlignment(Qt.AlignCenter)
        self.output_button = QPushButton("Select", self)
        self.output_button.setFixedWidth(100)
        self.output_button.clicked.connect(self.SelectOutputDir)
        output_layout = QGridLayout()
        output_layout.addWidget(self.output_check, 0, 0)
        output_layout.addWidget(self.output_path, 0, 1)
        output_layout.addWidget(self.output_button, 0, 2)
        output_box = QGroupBox("Output Directory", self)
        output_box.setLayout(output_layout)

        self.debug_check = QCheckBox("Debug", self)
        self.debug_check.setFixedWidth(80)
        self.start_button = QPushButton('Start', self)
        self.start_button.setFixedWidth(100)
        self.progressbar = QProgressBar(self)
        self.start_button.clicked.connect(self.Start)

        self.log = QTextEdit(self)
        self.log.setReadOnly(True)
        log_layout = QVBoxLayout()
        log_layout.addWidget(self.log)
        log_box = QGroupBox("Log", self)
        log_box.setLayout(log_layout)

        layout = QGridLayout()
        layout.addWidget(input_box, 0, 0, 1, 4)
        layout.addWidget(people_box, 1, 0, 1, 2)
        layout.addWidget(format_box, 1, 2, 1, 2)
        layout.addWidget(filter_box, 2, 0, 1, 2)
        layout.addWidget(output_box, 2, 2)
        layout.addWidget(self.debug_check, 2, 3)
        layout.addWidget(self.progressbar, 3, 0, 1, 3)
        layout.addWidget(self.start_button, 3, 3)
        layout.addWidget(log_box, 4, 0, 1, 4)

        self.setLayout(layout)
        self.show()

        self.SetPeopleFile(os.path.abspath("people.json"))
        self.SetFormatFile(os.path.abspath("format.json"))
        self.query_check.setChecked(True)
        self.query_check.clicked.emit()
        self.date_check.setChecked(False)
        self.date_check.clicked.emit()
        self.output_check.setChecked(True)
        self.output_check.clicked.emit()

        ##########STDOUT###########
        #printOccur=pyqtSignal(str)
        self.stream = io.TextIOBase()
        self.stream.write = self.write
        sys.stdout = self.stream
        print("Welcome")
Exemplo n.º 6
0
import sys
import io
import math

sum_data = lambda arg1, arg2: arg1 + arg2 * 4
print(sum_data(10, 20))
print(sys.getprofile())
print(io.TextIOBase())

print(dir(math))