File: utils.py

package info (click to toggle)
booth 1.0-283-g9d4029a-2%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 936 kB
  • sloc: ansic: 7,170; sh: 2,187; python: 471; makefile: 267; xml: 7
file content (19 lines) | stat: -rw-r--r-- 435 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import socket
import os
import sys

def get_IP():
    # IPv4 only for now
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        s.connect(('147.4.215.19', 9929))
        ret = s.getsockname()[0]
    except:
        ret = '127.0.0.1'
    finally:
        s.close()

    return ret

def use_single_instance():
    return ("--single-instance" in sys.argv) or (os.environ.get("BOOTH_RUNTESTS_SINGLE_INSTANCE") != None)