示例#1
0
文件: helpers.py 项目: scudella/SIP
def restart(wait=1, block=False):
    """
    Restarts the software from a new thread.
    
    @type wait: int
    @param wait: length of time to wait before rebooting
    @type block: bool
    @param block: If True, clear output and perform reboot after wait.
        Set to True at start of thread (recursive).
    """
    if block:
        report_restart()
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            print _('Restarting...')
        except Exception:
            pass
        gv.restarted = 0
        subprocess.Popen('systemctl restart sip.service'.split())
    else:
        t = Thread(target=restart, args=(wait, True))
        t.start()
示例#2
0
文件: helpers.py 项目: scudella/SIP
def reboot(wait=1, block=False):
    """
    Reboots the Raspberry Pi from a new thread.
    
    @type wait: int
    @param wait: length of time to wait before rebooting
    @type block: bool
    @param block: If True, clear output and perform reboot after wait.
        Set to True at start of thread (recursive).
    """
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            print _('Rebooting...')
        except Exception:
            pass
        subprocess.Popen(['reboot'])
    else:
        t = Thread(target=reboot, args=(wait, True))
        t.start()
示例#3
0
文件: helpers.py 项目: aocana/SIP
def reboot(wait=1, block=False):
    """
    Reboots the Raspberry Pi from a new thread.
    
    @type wait: int
    @param wait: length of time to wait before rebooting
    @type block: bool
    @param block: If True, clear output and perform reboot after wait.
        Set to True at start of thread (recursive).
    """
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            print _('Rebooting...')
        except Exception:
            pass
        subprocess.Popen(['reboot'])
    else:
        t = Thread(target=reboot, args=(wait, True))
        t.start()
示例#4
0
文件: helpers.py 项目: scudella/SIP
def poweroff(wait=1, block=False):
    """
    Powers off the Raspberry Pi from a new thread.
    
    @type wait: int or float
    @param wait: number of seconds to wait before rebooting
    @type block: bool
    @param block: If True, clear output and perform reboot after wait.
        Set to True at start of thread (recursive).
    """
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            print _('Powering off...')
        except Exception:
            pass
        subprocess.Popen(['poweroff'])
    else:
        t = Thread(target=poweroff, args=(wait, True))
        t.start()
示例#5
0
文件: helpers.py 项目: aocana/SIP
def poweroff(wait=1, block=False):
    """
    Powers off the Raspberry Pi from a new thread.
    
    @type wait: int or float
    @param wait: number of seconds to wait before rebooting
    @type block: bool
    @param block: If True, clear output and perform reboot after wait.
        Set to True at start of thread (recursive).
    """
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            print _('Powering off...')
        except Exception:
            pass
        subprocess.Popen(['poweroff'])
    else:
        t = Thread(target=poweroff, args=(wait, True))
        t.start()
示例#6
0
文件: helpers.py 项目: mirecta/SIP
def restart(wait=1, block=False):
    """
    Restarts the software from a new thread.
    Set to True at start of thread (recursive).
    """
    if block:
        report_restart()
        from gpio_pins import set_output

        gv.srvals = [0] * (gv.sd[u"nst"])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            print(_(u"Restarting..."))
        except Exception:
            pass
        gv.restarted = 0
        if six.PY2:
            subprocess.Popen(u"systemctl restart sip.service".split())
        elif six.PY3:
            subprocess.Popen(u"systemctl restart sip3.service".split())
    else:
        t = Thread(target=restart, args=(wait, True))
        t.start()
示例#7
0
def restart(wait=1, block=False):
    """
    Restarts the software from a new thread.
    Set to True at start of thread (recursive).
    """
    if block:
        report_restart()
        from gpio_pins import set_output

        gv.srvals = [0] * (gv.sd[u"nst"])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            print(_(u"Restarting..."))
        except Exception:
            pass
        gv.restarted = 0
        pid = os.getpid()
        command = u"systemctl status " + str(pid)
        output = str(subprocess.check_output(command.split()))
        unit_name = output.split()[1]
        command = u"systemctl restart " + unit_name
        subprocess.Popen(command.split())
    else:
        t = Thread(target=restart, args=(wait, True))
        t.start()
示例#8
0
文件: helpers.py 项目: bkoblenz/SIP
def restart(wait=1, block=False):
    """
    Restarts the software from a new thread.
    
    @type wait: int
    @param wait: length of time to wait before rebooting
    @type block: bool
    @param block: If True, clear output and perform reboot after wait.
        Set to True at start of thread (recursive).
    """
    if block:
        report_restart()
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            gv.logger.info(_('Restarting...'))
        except Exception:
            pass
        subprocess.Popen('service sip restart'.split())
    else:
        t = Thread(target=restart, args=(wait, True))
        t.start()
示例#9
0
def poweroff(wait=1, block=False):
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        GPIO.cleanup()
        time.sleep(wait)
        try:
            print _('Powering off...')
        except Exception:
            pass
        subprocess.Popen(['poweroff'])
    else:
        t = Thread(target=poweroff, args=(wait, True))
        t.start()
示例#10
0
文件: helpers.py 项目: ntc490/OSPi
def poweroff(wait=1, block=False):
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        GPIO.cleanup()
        time.sleep(wait)
        try:
            print _('Powering off...')
        except Exception:
            pass
        subprocess.Popen(['poweroff'])
    else:
        t = Thread(target=poweroff, args=(wait, True))
        t.start()
示例#11
0
文件: helpers.py 项目: ntc490/OSPi
def restart(wait=1, block=False):
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        try:
            GPIO.cleanup()
        except Exception:
            pass
        time.sleep(wait)
        try:
            print _('Restarting...')
        except Exception:
            pass
        subprocess.Popen('service ospi restart'.split())
    else:
        t = Thread(target=restart, args=(wait, True))
        t.start()
示例#12
0
def restart(wait=1, block=False):
    if block:
        from gpio_pins import set_output
        gv.srvals = [0] * (gv.sd['nst'])
        set_output()
        try:
            GPIO.cleanup()
        except Exception:
            pass
        time.sleep(wait)
        try:
            print _('Restarting...')
        except Exception:
            pass
        subprocess.Popen('service ospi restart'.split())
    else:
        t = Thread(target=restart, args=(wait, True))
        t.start()
示例#13
0
文件: helpers.py 项目: mirecta/SIP
def reboot(wait=1, block=False):
    """
    Reboots the Raspberry Pi from a new thread.
    Set to True at start of thread (recursive).
    """
    if block:
        from gpio_pins import set_output

        gv.srvals = [0] * (gv.sd[u"nst"])
        set_output()
        if gv.use_pigpio:
            pass
        else:
            GPIO.cleanup()
        time.sleep(wait)
        try:
            print(_(u"Rebooting..."))
        except Exception:
            pass
        subprocess.Popen([u"reboot"])
    else:
        t = Thread(target=reboot, args=(wait, True))
        t.start()