def convert_to_netlist(filename):
    utils.spawn(['bash', utils.local_file('eeschema-to-netlist.sh'), filename])
    netlist = filename.replace('.sch', '.cir')
    if path.exists(netlist):
        return (filename, netlist)
    else:
        return (filename, None)
Ejemplo n.º 2
0
 def run(self):
     info('UDP Over TCP Server start on', config.server_listen_addr)
     info('Server will relay data to', config.remote_udp)
     while True:
         conn, addr = self.s.accept()
         log(addr, 'connect in')
         # t = Thread(target=self.handle, args=(conn, addr))
         # t.setDaemon(True)
         # t.start()
         spawn(target=self.handle, args=(conn, addr))
Ejemplo n.º 3
0
    def run(self):
        pid = os.getpid()
        log('my PID:', pid)
        with open('pid.txt', 'w') as f:
            f.write(str(pid))

        for p in config.servers:
            q = queue.Queue()
            self.sign_queues.append(q)
            s = Shaddock(p, config.servers[p], q)
            log('listen on:', p)
            spawn(s.run, daemon=False)
Ejemplo n.º 4
0
    def run(self):
        s = socket.socket()
        s.connect(config.server_listen_addr)
        # t = Thread(target=self.relay, args=(s, self.c))
        # t.setDaemon(True)
        # t.start()
        spawn(target=self.relay, args=(s, self.c))

        while True:
            data, self.game_addr = self.c.recvfrom(4096)
            log('local -> server:', data)
            s.sendall(str(len(data)).encode() + b'\n' + data)
Ejemplo n.º 5
0
 def handle(self, conn, addr):
     c = self.udp_client(addr)
     # t = Thread(target=self.relay, args=(c, conn))
     # t.setDaemon(True)
     # t.start()
     spawn(target=self.relay, args=(c, conn))
     while True:
         data = recv(conn)
         log('client -> remote:', data)
         if (data is None) or rand_err():
             conn.close()
             return
         c.sendto(data, config.remote_udp)
Ejemplo n.º 6
0
def recordSession(stop=0):
    """Record the current pyFormex session."""
    global _recording_pid
    from guimain import hasDRI

    print("RECORDING with dri=%s" % pf.options.dri)

    ok = utils.checkExternal('recordmydesktop')
    if not ok:
        return
    if hasDRI():
        if not draw.ack(
                "Recording the session while using DRI may fail to correctly capture the OpenGL canvas. We recommend starting pyformex with the --nodri option to do session recording (at the expense of a slower execution). If you click YES I will nevertheless go ahead with recording."
        ):
            return

    fn = draw.askFilename(pf.cfg['workdir'],
                          "Theora video files (*.ogv)",
                          exist=False)
    if not fn:
        return

    print("Recording your session to file %s" % fn)
    x, y, w, h = pf.GUI.XGeometry()
    cmd = "recordmydesktop -x %s -y %s --width %s --height %s --no-frame -o %s" % (
        x, y, w, h, fn)
    print(cmd)
    pid = utils.spawn(cmd)
    print("Recording pid = %s" % pid)
    _recording_pid = pid
Ejemplo n.º 7
0
def recordSession(stop=0):
    """Record the current pyFormex session."""
    global _recording_pid
    from guimain import hasDRI

    print("RECORDING with dri=%s" % pf.options.dri)

    ok = utils.checkExternal('recordmydesktop')
    if not ok:
        return
    if hasDRI():
        if not draw.ack("Recording the session while using DRI may fail to correctly capture the OpenGL canvas. We recommend starting pyformex with the --nodri option to do session recording (at the expense of a slower execution). If you click YES I will nevertheless go ahead with recording."):
            return

    fn = draw.askFilename(pf.cfg['workdir'],"Theora video files (*.ogv)",exist=False)
    if not fn:
        return

    print("Recording your session to file %s" % fn)
    x,y,w,h = pf.GUI.XGeometry()
    cmd = "recordmydesktop -x %s -y %s --width %s --height %s --no-frame -o %s" % (x,y,w,h,fn)
    print(cmd)
    pid = utils.spawn(cmd)
    print("Recording pid = %s" % pid)
    _recording_pid = pid
Ejemplo n.º 8
0
 def _connect(self, **opts):
     """
     Attempt to connect to ftp server
     :return:
     :raises: exc.ConnectionError, exc.LoginError
     """
     cmd = ['lftp']
     cmd += ['-p', str(self.port)]
     cmd += ['-u', "%s,%s" % (self.username, self.password), self.host]
     process = spawn(" ".join(cmd))
     self.process = process
     # ensure that we can connect
     index = self.process.expect([self.prompt, EOF])
     output = self.process.before
     if index == 0:
         output = output + self.process.after
     if "Name or service not known" in output:
         raise exc.ConnectionError(output)
     # ensure that we are logged in
     # We do this by trying to send a command and
     # testing to see if there's a login error
     self.process.sendline("ls -la")
     index = self.process.expect([self.prompt, EOF, TIMEOUT])
     output = self.process.before
     if "Login failed" in output:
         raise exc.LoginError(output)
Ejemplo n.º 9
0
    def run(self):
        s = socket.socket()
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.bind(('0.0.0.0', self.port))
        s.listen(5)

        while True:
            conn, addr = s.accept()

            if not self.reload_sign.empty():
                self.reload_sign.get()
                self.load_ssl_ctxs()

            if self.ssl_enabled():
                spawn(self.ssl_wrap_handle, (conn, addr))
            else:
                spawn(self.handle, (conn, addr))
Ejemplo n.º 10
0
    def start(self):
        self._udp_sock = utils.socket.socket(utils.socket.AF_INET,
                                           utils.socket.SOCK_DGRAM)
        self._udp_sock.bind((self._address, self._port))

        t = utils.spawn(self._recv_loop)
        super(SFlow, self).start()
        return t
Ejemplo n.º 11
0
    def _recv_loop(self):
        self.logger.info('Listening on %s:%s for sflow agents' %
                         (self._address, self._port))

        while True:
            buf, addr = self._udp_sock.recvfrom(self._udp_msg_size)
            t = utils.spawn(self._handle, buf, addr)
            self.threads.append(t)
Ejemplo n.º 12
0
def edit():
    """Load the current file in the editor.

    This only works if the editor was set in the configuration.
    The author uses 'gnuclient' to load the files in a running copy
    of xemacs.
    """
    if GD.cfg['editor']:
        pid = utils.spawn(GD.cfg['editor'] % GD.cfg['curfile'])
Ejemplo n.º 13
0
def tempIDL(inFile, fType=0, double=True):
    """
  Read in binary TAPE files (inFile), save data to IDL save files,
  and then read them with Python for plotting. this is pretty time-
  consuming

  This is a temporary function until I figure out how to read in
  FORTRAN binary files in Python (looks like it can be done --
  https://stackoverflow.com/questions/37534220/python-read-fortran-binary-file)

  Input
    inFile -- string, path to binary TAPE (10, 11, 12, 13)
      output_file from LBLRTM

  Output

  Keywords
    fType -- int, file type (radiance, transmittance, etc.; see doc in
      /project/rc/rc2/mshep/idl/patbrown/read_lbl_file_dbl.pro)
    double -- boolean, is inFile in double precision? defaults to yes

  """

    from scipy.io.idl import readsav
    import utils

    # write_save_file.pro is in this Git repo:
    # https://lex-gitlab.aer.com/rpernak/common_modules
    # and is considered, along with the RC_utils.py and utils.py
    # modules, part of the RC common library
    proFile = 'write_save_file.pro'
    #if not os.path.exists(proFile):
    #  os.symlink('externals/common/%s' % proFile, proFile)

    if double:
        proCall = \
          "write_save_file, \'%s\', file_type=%d, /dbl" % (inFile, fType)
    else:
        proCall = \
          "write_save_file, \'%s\', file_type=%d" % (inFile, fType)
    # endif double

    idlCmd = 'idl -e "%s"' % proCall
    sOut, sErr = utils.spawn(idlCmd)

    # write_save_file.pro always writes a LBLRMT_output.sav file
    # and contains the wavenum and spectrum arrays
    tempSav = 'LBLRTM_output.sav'
    idlDat = readsav(tempSav)
    waveNum, param = idlDat['wavenum'], idlDat['spectrum']
    os.remove(tempSav)
    #os.remove(proFile)

    return {'wavenumber': waveNum, 'spectrum': param}
Ejemplo n.º 14
0
def edit():
    """Load the current file in the editor.

    This only works if the editor was set in the configuration.
    The author uses 'gnuclient' to load the files in a running copy
    of (X)Emacs.
    """
    if GD.cfg['editor']:
        pid = utils.spawn('%s %s' % (GD.cfg['editor'],GD.cfg['curfile']))
    else:
        draw.warning('No known editor was found or configured')
Ejemplo n.º 15
0
def editScript(fn=None):
    """Load the current file in the editor.

    This only works if the editor was set in the configuration.
    The author uses 'emacsclient' to load the files in a running copy
    of Emacs.
    If a filename is specified, that file is loaded instead.
    """
    if GD.cfg['editor']:
        if fn is None:
            fn = GD.cfg['curfile']
        pid = utils.spawn('%s %s' % (GD.cfg['editor'],fn))
    else:
        draw.warning('No known editor was found or configured')
Ejemplo n.º 16
0
def help(page=None):
    """Display a html help page.

    If GD.help.viewer == None, the help page is displayed using the
    built-in help browser. GD.help.viewer can be set to a string to
    display the page in an external browser.
    """
    if not page:
        page = GD.cfg['help/manual']
    if page.startswith('http:'):
        browser = GD.cfg['browser']
    else:
        browser = GD.cfg['viewer']
    pid = utils.spawn(browser % page)
Ejemplo n.º 17
0
def help(page=None):
    """Display a html help page.

    If no page is specified, the help manual is displayed.

    If page is a string starting with 'http:', the page is displayed with
    the command set in pf.cfg['browser'], else with the command in
    pf.cfg['viewer']
    """
    if not page:
        page = pf.cfg['help/manual']
    if page.startswith('http:') or page.startswith('file:'):
        browser = pf.cfg['browser']
    else:
        browser = pf.cfg['viewer']
    pid = utils.spawn(' '.join([browser,page]))
Ejemplo n.º 18
0
def help(page=None):
    """Display a html help page.

    If no page is specified, the help manual is displayed.

    If page is a string starting with 'http:', the page is displayed with
    the command set in pf.cfg['browser'], else with the command in
    pf.cfg['viewer']
    """
    if not page:
        page = pf.cfg['help/manual']
    if page.startswith('http:') or page.startswith('file:'):
        browser = pf.cfg['browser']
    else:
        browser = pf.cfg['viewer']
    pid = utils.spawn(' '.join([browser, page]))
Ejemplo n.º 19
0
    def forward(self, ctx):
        up_url = URL(ctx.cfg['upstream'])

        if up_url.protocol == Protocol.unix:
            right_conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
            right_conn.connect(up_url.host)
        else:
            right_conn = socket.socket()
            right_conn.connect((up_url.host, up_url.port))
        right_conn.sendall(ctx.header.encode())

        t = spawn(self.relay, (ctx.left_conn, right_conn))
        self.relay(right_conn, ctx.left_conn)
        t.join()

        ctx.left_conn.close()
        right_conn.close()
Ejemplo n.º 20
0
 def spawn(self, city):
     return spawn(self.shape, city, self.fill)
Ejemplo n.º 21
0
 def start(self):
     self.threads.append(utils.spawn(self._event_loop))
Ejemplo n.º 22
0
 def supervisor(self):
     info('UDP Over TCP Client start on', config.client_listen_addr)
     while True:
         t = spawn(target=self.run)
         t.join()
         info('Reconnect...')