def __init__(self):
     self.all_triggers = self.get_all_triggers()
     self.all_payloads = self.get_all_payloads()
     # Constants
     self.CURRENT_OS = psystem()
     self.ROOT_DIRECTORY = '/' if opath.abspath(
         executable)[0] is None else opath.abspath(executable)[0]
     self.file_creator_obj = FileCreator(current_os=self.CURRENT_OS,
                                         root_directory=self.ROOT_DIRECTORY)
示例#2
0
def startWeb(p, resourcePath, nonesym, timec, timebg, btc, btbg, etc, etbg,
             showetflag, showbtflag):
    global port, process, static_path, nonesymbol, timecolor, timebackground, btcolor, btbackground, etcolor, etbackground, showet, showbt
    try:
        port = p
        static_path = resourcePath
        nonesymbol = nonesym
        timecolor = timec
        timebackground = timebg
        btcolor = btc
        btbackground = btbg
        etcolor = etc
        etbackground = etbg
        showet = showetflag
        showbt = showbtflag
        if psystem() != 'Windows':
            gsignal(SIGQUIT, kill)

        # start the server in a separate process


# using multiprocessing
        process = mProcess(target=work,
                           args=(
                               port,
                               resourcePath,
                               nonesym,
                               timec,
                               timebg,
                               btc,
                               btbg,
                               etc,
                               etbg,
                               showetflag,
                               showbtflag,
                           ))
        process.start()

        libtime.sleep(4)

        # check successful start
        url = "http://127.0.0.1:" + str(port) + "/status"
        r = rget(url, timeout=2)

        if r.status_code == 200:
            return True
        else:
            return False

    except Exception:
        #        import traceback
        #        import sys
        #        traceback.print_exc(file=sys.stdout)
        return False
示例#3
0
def startWeb(p,resourcePath,nonesym,timec,timebg,btc,btbg,etc,etbg,showetflag,showbtflag):
    global port, process, static_path, nonesymbol, timecolor, timebackground, btcolor, btbackground, etcolor, etbackground, showet, showbt
    try:
        port = p
        static_path = resourcePath
        nonesymbol = nonesym
        timecolor = timec
        timebackground = timebg
        btcolor = btc
        btbackground = btbg
        etcolor = etc
        etbackground = etbg
        showet = showetflag
        showbt = showbtflag
        if psystem() != 'Windows':
            gsignal(SIGQUIT, kill)
        
        # start the server in a separate process
# using multiprocessing
        process = mProcess(target=work,args=(
            port,
            resourcePath,
            nonesym,
            timec,
            timebg,
            btc,
            btbg,
            etc,
            etbg,
            showetflag,
            showbtflag,))
        process.start()
       
        libtime.sleep(4)
        
        # check successful start
        url = "http://127.0.0.1:" + str(port) + "/status"
        r = rget(url,timeout=2)
        
        if r.status_code == 200:
            return True
        else:
            return False

    except Exception:
#        import traceback
#        import sys
#        traceback.print_exc(file=sys.stdout)
        return False
示例#4
0
def startWeb(p, resourcePath, nonesym, timec, timebg, btc, btbg, etc, etbg,
             showetflag, showbtflag):
    global port, process, static_path, nonesymbol, timecolor, timebackground, btcolor, btbackground, etcolor, etbackground, showet, showbt
    port = p
    static_path = resourcePath
    nonesymbol = nonesym
    timecolor = timec
    timebackground = timebg
    btcolor = btc
    btbackground = btbg
    etcolor = etc
    etbackground = etbg
    showet = showetflag
    showbt = showbtflag
    if psystem() != 'Windows':
        gsignal(SIGQUIT, kill)

    process = mp.Process(name='WebLCDs',
                         target=work,
                         args=(
                             port,
                             resourcePath,
                             nonesym,
                             timec,
                             timebg,
                             btc,
                             btbg,
                             etc,
                             etbg,
                             showetflag,
                             showbtflag,
                         ))
    process.start()

    libtime.sleep(4)

    if process.is_alive():
        # check successful start
        url = "http://127.0.0.1:" + str(port) + "/status"
        r = rget(url, timeout=2)

        if r.status_code == 200:
            return True
        else:
            return False
    else:
        return False
示例#5
0
from os.path import splitext, join, isfile, dirname
from warnings import warn

libfullpath = r'$libraryfullpath$'
if not isfile(libfullpath) and osname=='nt':
    if isfile(join(dirname(__file__), libfullpath)):
        libfullpath = join(dirname(__file__), libfullpath)

#libname, ext = splitext(libfullpath)
libname = libfullpath.split('.')[0]
ext ='.'+ '.'.join(libfullpath.split('.')[1:])
# must use ctypes.RTLD_GLOBAL for threading support
ctypes._dlopen(libfullpath, ctypes.RTLD_GLOBAL)
lib = ctypes.cdll.LoadLibrary(libfullpath)

if psystem() == 'Windows':
    lib_threads = libname
else:
    lib_threads = libname + '_threads'+ ext
try:
    lib_threads = ctypes.cdll.LoadLibrary(lib_threads)
except OSError, e:
    warn("Could not load threading library %s, threading support is disabled"
         %lib_threads)
    lib_threads = None


_typelist =    [('$libname$_plan_dft_1d', (typeDict['$complex$'], typeDict['$complex$'], 1)),
                       ('$libname$_plan_dft_2d', (typeDict['$complex$'], typeDict['$complex$'], 2)),
                       ('$libname$_plan_dft_3d', (typeDict['$complex$'], typeDict['$complex$'], 3)),
                       ('$libname$_plan_dft', (typeDict['$complex$'], typeDict['$complex$'])),
示例#6
0
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.

# AUTHOR
# Marko Luther, 2018

from bottle import default_app, request, abort, route, template, static_file, get, TEMPLATE_PATH
from gevent import Timeout, signal as gsignal, kill
from gevent.pywsgi import WSGIServer
#from geventwebsocket import WebSocketError
from geventwebsocket.handler import WebSocketHandler
from platform import system as psystem

if psystem() != 'Windows':
    from signal import SIGQUIT

from multiprocessing import Process as mProcess

from json import dumps as jdumps
from requests import get as rget

import time as libtime

wsocks = []  # list of open web sockets
process = None
port = None
nonesymbol = "--"
timecolor = "#FFF"
timebackground = "#000"
示例#7
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from bottle import default_app, request, abort, route, template, static_file, get, TEMPLATE_PATH
from gevent import Timeout, signal as gsignal, kill
from gevent.pywsgi import WSGIServer
#from geventwebsocket import WebSocketError
from geventwebsocket.handler import WebSocketHandler
from platform import system as psystem

if psystem() != 'Windows':
    from signal import SIGQUIT

from multiprocessing import Process as mProcess

from json import dumps as jdumps
from requests import get as rget

import time as libtime

wsocks = [] # list of open web sockets
process = None
port = None
nonesymbol = "--"
timecolor="#FFF"
timebackground="#000"
btcolor="#00007F"
btbackground="#CCCCCC"
etcolor="#FF0000"
etbackground="#CCCCCC"
showet = True
示例#8
0
文件: weblcds.py 项目: seckar/artisan
def startWeb(p, resourcePath, nonesym, timec, timebg, btc, btbg, etc, etbg,
             showetflag, showbtflag):
    global port, process, static_path, nonesymbol, timecolor, timebackground, btcolor, btbackground, etcolor, etbackground, showet, showbt
    port = p
    static_path = resourcePath
    nonesymbol = nonesym
    timecolor = timec
    timebackground = timebg
    btcolor = btc
    btbackground = btbg
    etcolor = etc
    etbackground = etbg
    showet = showetflag
    showbt = showbtflag
    if psystem() != 'Windows':
        gsignal(SIGQUIT, kill)

    # start the server in a separate process
    # using multiprocessing
    if psystem() == 'Darwin':
        try:
            # start method can only be set once!
            #            if "fork" in mp.get_all_start_methods():
            #                mp.set_start_method('fork') # default on Python3.7 for macOS (and Unix), but considered unsafe,
            # not available on Windows, on Python3.8 we have to explicitly set this
            # https://bugs.python.org/issue33725
            if "forkserver" in mp.get_all_start_methods():
                mp.set_start_method(
                    'forkserver'
                )  # only available on Python3 on Unix, currently (Python 3.8) not supported by frozen executables generated with pyinstaller


#            if "spawn" in mp.get_all_start_methods():
#                mp.set_start_method('spawn') # default on Python3.8 for macOS (always default on Windows)
# this breaks on starting WebLCDs in macOS (and linux) builds with py2app, pyinstaller
# https://bugs.python.org/issue32146
# https://github.com/pyinstaller/pyinstaller/issues/4865
        except:
            pass
    process = mp.Process(name='WebLCDs',
                         target=work,
                         args=(
                             port,
                             resourcePath,
                             nonesym,
                             timec,
                             timebg,
                             btc,
                             btbg,
                             etc,
                             etbg,
                             showetflag,
                             showbtflag,
                         ))
    process.start()

    libtime.sleep(4)

    if process.is_alive():
        # check successful start
        url = "http://127.0.0.1:" + str(port) + "/status"
        r = rget(url, timeout=2)

        if r.status_code == 200:
            return True
        else:
            return False
    else:
        return False
             %'libfftw3.so')
    libfullpath = r'libfftw3.so.3'

if not isfile(libfullpath) and (osname=='nt' or psystem=='Windows'):
    if isfile(joinpath(dirname(__file__), libfullpath)):
        libfullpath = joinpath(dirname(__file__), libfullpath)

# must use ctypes.RTLD_GLOBAL for threading support
ctypes._dlopen(libfullpath, ctypes.RTLD_GLOBAL)
lib = ctypes.cdll.LoadLibrary(libfullpath)
#check if library is actually loaded there doesn't seem to be a better way to
#do this in ctypes
if not hasattr(lib, 'fftw_plan_dft_1d'):
    raise OSError('Could not load libfftw3.so')

if osname == 'nt' or psystem() == 'Windows':
    lib_threads = lib
else:
    libbase,ext = libfullpath.split('.', 1)
    libdir = dirname(libfullpath)
    lib_threads = joinpath(libdir, libbase + '_threads.'+ ext)
    try:
        lib_threads = ctypes.cdll.LoadLibrary(lib_threads)
    except OSError, e:
        warn("Could not load threading library %s, threading support is disabled"
            %lib_threads)
        lib_threads = None


_typelist =    [('fftw_plan_dft_1d', (typeDict['complex'], typeDict['complex'], 1)),
                       ('fftw_plan_dft_2d', (typeDict['complex'], typeDict['complex'], 2)),