Exemple #1
0
def checkup_on_dms():
    if not exists(common.DMS_UDS_PATH):
        start(['./server.py'])
    for i in xrange(30):
        if exists(common.DMS_UDS_PATH): 
            return
        sleep(0.1)
    fatal("Error: Could not start pydms service. Giving up.")
Exemple #2
0
def say(phrase, beep=True):
    if beep:
        #old: start("speaker-test -t sine -f 700 -l 1 -P 2 -c 1& a=$(jobs -p | head); echo $a; sleep 0.2; kill -KILL $a;")
        #start("ffplay -nodisp -autoexit ~/dotfiles/Ching4.wav")
        #start("ffplay -nodisp -autoexit ~/dotfiles/bell2.ogg")
        start("ffplay -nodisp -autoexit ~/dotfiles/bell.ogg")

    #start("flite -t '{}'".format(phrase))
    start("espeak '{}'".format(phrase))
Exemple #3
0
    def __init__(self, cores=None, version=None, timeout=60):

        # Start the Comsol server as an external process.
        backend = discovery.backend(version)
        command = backend['server']
        logger.info('Starting external server process.')
        if cores:
            command += ['-np', str(cores)]
            noun = 'core' if cores == 1 else 'cores'
            logger.info(f'Server restricted to {cores} processor {noun}.')
        process = start(command, stdin=PIPE, stdout=PIPE)

        # Wait for it to report the port number.
        t0 = now()
        while process.poll() is None:
            line = process.stdout.readline().decode()
            match = regex(r'^.*listening on port *(\d+)', line)
            if match:
                port = int(match.group(1))
                break
            if now() - t0 > timeout:
                error = 'Sever failed to start within time-out period.'
                logger.error(error)
                raise TimeoutError(error)
        logger.info(f'Server listening on port {port}.')

        # Save useful information in instance attributes.
        self.version = backend['name']
        self.cores = cores
        self.port = port
        self.process = process
Exemple #4
0
    def __init__(self, cores=None, version=None, timeout=60):

        # Start the Comsol server as an external process.
        backend = discovery.backend(version)
        server = backend['server']
        logger.info('Starting external server process.')
        if cores:
            arguments = ['-np', str(cores)]
            noun = 'core' if cores == 1 else 'cores'
            logger.info(f'Server restricted to {cores} processor {noun}.')
        else:
            arguments = []
        arguments += ['-login', 'auto']
        command = server + arguments
        if version_info < (3, 8):
            command[0] = str(command[0])
        process = start(command, stdin=PIPE, stdout=PIPE, errors='ignore')

        # Wait for the server to report the port number.
        t0 = now()
        lines = []
        port = None
        while process.poll() is None:
            line = process.stdout.readline().strip()
            if line:
                lines.append(line)
            match = regex(r'(?i)^Comsol.+?server.+?(\d+)$', line.strip())
            if match:
                port = int(match.group(1))
                break
            if now() - t0 > timeout:
                error = 'Sever failed to start within time-out period.'
                logger.critical(error)
                raise TimeoutError(error)

        # Bail out if server exited with an error.
        # We don't use `process.returncode` here, as we would like to,
        # because on Linux the server executable exits with code 0,
        # indicating no error, even when an error has occurred.
        # We assume that the last line in the server's output is the
        # actual error message.
        if port is None:
            error = f'Starting server failed: {lines[-1]}'
            logger.critical(error)
            raise RuntimeError(error)
        logger.info(f'Server listening on port {port}.')

        # Save useful information in instance attributes.
        self.version = backend['name']
        self.cores = cores
        self.port = port
        self.process = process
Exemple #5
0
    def __init__(self, cores=None, version=None, timeout=60):

        # Start the Comsol server as an external process.
        backend = discovery.backend(version)
        server  = backend['server']
        logger.info('Starting external server process.')
        if cores:
            arguments = ['-np', str(cores)]
            noun = 'core' if cores == 1 else 'cores'
            logger.info(f'Server restricted to {cores} processor {noun}.')
        else:
            arguments = []
        process = start(server + arguments, stdin=PIPE, stdout=PIPE)

        # Wait for it to report the port number.
        t0 = now()
        while process.poll() is None:
            peek = process.stdout.peek().decode()
            if peek.startswith('Username:'******'User name and password for Comsol server not set.'
                logger.error(error)
                logger.error('Start it manually from a system console first:')
                logger.error(' '.join(str(part) for part in server))
                raise RuntimeError(error)
            line = process.stdout.readline().decode()
            match = regex(r'^.*listening on port *(\d+)', line)
            if match:
                port = int(match.group(1))
                break
            if now() - t0 > timeout:
                error = 'Sever failed to start within time-out period.'
                logger.error(error)
                raise TimeoutError(error)
        logger.info(f'Server listening on port {port}.')

        # Save useful information in instance attributes.
        self.version = backend['name']
        self.cores   = cores
        self.port    = port
        self.process = process
Exemple #6
0
    def __init__(self, cores=None, version=None, timeout=60):

        # Start the Comsol server as an external process.
        folder = backend.folder(version)
        architecture = backend.architecture()
        if system() == 'Windows':
            executable = 'comsolmphserver'
            arguments  = ''
        else:
            executable = 'comsol'
            arguments  = ' mphserver'
        fullpath = folder / 'bin' / architecture / executable
        command = f'{fullpath}{arguments}'
        logger.info('Starting external server process.')
        if cores:
            command += f' -np {cores}'
            noun = 'core' if cores == 1 else 'cores'
            logger.info(f'Server restricted to {cores} processor {noun}.')
        process = start(command, stdin=PIPE, stdout=PIPE)

        # Wait for it to report the port number.
        t0 = now()
        while process.poll() is None:
            line = process.stdout.readline().decode()
            match = regex(r'^.*listening on port *(\d+)', line)
            if match:
                port = int(match.group(1))
                break
            if now() - t0 > timeout:
                error = 'Sever failed to start within time-out period.'
                logger.error(error)
                raise TimeoutError(error)
        logger.info(f'Server listening on port {port}.')

        # Remember setup in instance attributes.
        self.port    = port
        self.cores   = cores
        self.process = process
        self.version = version
        self.folder  = folder
Exemple #7
0
    for stdout_line in iter(popen.stdout.readline, ""):
        yield stdout_line
    popen.stdout.close()
    return_code = popen.wait()
    if return_code:
        raise subprocess.CalledProcessError(return_code, cmd)


ffmpeg = "D:\\progs\\ffmpeg-2020-09-27-git-a3a6b56200-full_build\\bin\\ffmpeg.exe"
opt = " -i \"{}\" -vf fps=1 -qscale:v 2 {}\\{}%04d.jpg"
filename = sys.argv[1]
shortname = "scr_" + sys.argv[1].replace(" ", "").replace("&", "")

if not os.path.exists(shortname):
    os.makedirs(shortname)

cmdline = ffmpeg + opt.format(filename, shortname, shortname)
print(cmdline)
#start(cmdline)
for path in execute(cmdline):
    print(path, end="")

print("OK extract screenshots")

zipper = "D:\\progs\\7-Zip\\7z.exe"
zipopt = " a -sdel {}.zip {}"
cmdline = zipper + zipopt.format(shortname, shortname)
print(cmdline)
start(cmdline)
print("OK  zipped")
Exemple #8
0
import codecs
import random
from subprocess import getoutput as start
from pathlib import Path
import os
pwd = os.getcwd()
files = list(Path(".").rglob("*.*"))

n = len(files)
r = random.randint(1, n)
randomfile = pwd + ".\\" + str(files[r])
print(randomfile)
start("D:\progs\iview454_x64\i_view64.exe " + randomfile)
    
Exemple #9
0
def deploy(repo,rev):
      from subprocess import Popen as start
      import subprocess
      
      cmd = "python /opt/auto/svn/bin/svncheck.py %s %s" % (repo, rev) 
      p = start(cmd,shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Exemple #10
0
def starting(text, ring=True):
    if not TEST and ring:
        start("ffplay -nodisp -autoexit ~/dotfiles/bell.ogg")
    start("espeak '{}'".format(text))
Exemple #11
0
def ending(is_say=True):
    if is_say:
        start("espeak '{}'".format('ok'))
Exemple #12
0
def deploy(repo, rev):
    from subprocess import Popen as start
    import subprocess

    cmd = "python /opt/auto/svn/bin/svncheck.py %s %s" % (repo, rev)
    p = start(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)