Esempio n. 1
0
 def on_timeout(self):
     try:
         f = open("main.py")
         f.close()
         os.exec("main.py")
     except OSError:
         pass
Esempio n. 2
0
def main():
    create_folders()
    disp = display.open()
    applist = list_apps()
    numapps = len(applist)
    current = 0
    lineoffset = 0
    timerscrollspeed = 1
    timerstartscroll = 5
    timercountpopped = 0
    for ev in button_events(10):
        if numapps == 0:
            disp.clear(color.COMMYELLOW)
            disp.print(
                " No apps ",
                posx=17,
                posy=20,
                fg=color.COMMYELLOW_DARK,
                bg=color.COMMYELLOW,
            )
            disp.print(
                "available",
                posx=17,
                posy=40,
                fg=color.COMMYELLOW_DARK,
                bg=color.COMMYELLOW,
            )
            disp.update()
            continue

        if ev == buttons.BOTTOM_RIGHT:
            # Scroll down
            current = (current + 1) % numapps
            lineoffset = 0
            timercountpopped = 0

        elif ev == buttons.BOTTOM_LEFT:
            # Scroll up
            current = (current + numapps - 1) % numapps
            lineoffset = 0
            timercountpopped = 0

        elif ev == BUTTON_TIMER_POPPED:
            timercountpopped += 1
            if (timercountpopped >= timerstartscroll and
                (timercountpopped - timerstartscroll) % timerscrollspeed == 0):
                lineoffset += 1

        elif ev == buttons.TOP_RIGHT:
            # Select & start
            disp.clear().update()
            disp.close()
            try:
                os.exec(applist[current][0])
            except OSError as e:
                print("Loading failed: ", e)
                os.exit(1)

        draw_menu(disp, applist, current, numapps, lineoffset)
Esempio n. 3
0
 def on_select(self, app, index):
     self.disp.clear().update()
     try:
         print("Trying to load " + app.path)
         os.exec(app.path)
     except OSError as e:
         print("Loading failed: ")
         sys.print_exception(e)
         self.error("Loading", "failed")
         utime.sleep(1.0)
         os.exit(1)
Esempio n. 4
0
def main():
    # Try loading analog clock
    default_app = "apps/analog_clock/__init__.py"
    try:
        with open(default_app, "r"):
            pass

        print("main.py: Loading " + default_app)
        os.exec(default_app)
    finally:
        os.exit(1)
Esempio n. 5
0
    def on_select(self, app, index):
        self.disp.clear().update()
        try:
            if app.path == "USB_STORAGE_FLAG":
                usb_mode(self.disp)
                return

            print("Trying to load " + app.path)
            os.exec(app.path)
        except OSError as e:
            print("Loading failed: ")
            sys.print_exception(e)
            self.error("Loading", "failed")
            utime.sleep(1.0)
            os.exit(1)
Esempio n. 6
0
def submitSlurmJob(jobname,account, queueName, ntasks, nnodes, jobTime, modules):
    slurmScript="""#!/bin/bash
#
# Simple SLURM script for submitting multiple serial
# jobs (e.g. parametric studies) using a script wrapper
# to launch the jobs.
#
#------------------Scheduler Options--------------------
"""
    try:
        test=int(nnodes)
    except:
        print("Number of nodes must be an integer not " + nnodes)
        sys.exit(1)
    try:
        test=int(ntasks)
    except:
        print("Number of tasks on a node must be an integer not " + ntasks)
        sys.exit(1) 
    try:
        if jobTime.count(':') != 2:
            print("Job time must be formatted in hh:mm:ss format not " + jobTime)
            sys.exit(1)
        x=jobTime.split(':')
        for y in x:
            test=int(y)
    except:
        print("Job time must be formatted in hh:mm:ss format not " + jobTime)
        sys.exit(1)
# should probably look at jobname and scrub it for bad characters
# and call sinfo to get the list of slurm queues and make sure this is valid
# but Im bored now
    slurmScript = slurmScript + "#SBATCH -J " + jobname +"\n"
    slurmScript = slurmScript + "#SBATCH -N " + nnodes +"\n"
    slurmScript = slurmScript + "#SBATCH -n " + ntasks +"\n"
    slurmScript = slurmScript + "#SBATCH -p " + queueName +"\n"
    slurmScript = slurmScript + "#SBATCH -o " + jobname +".o%j\n"
    slurmScript = slurmScript + "#SBATCH -t " + jobTime +"\n"
    slurmScript = slurmScript + "#SBATCH -A " + account +"\n"
    for module in modules.split(','):
       slurmScript=slurmScript+"module load " + module +"\n"
    slurmScript = slurmScript+"runner.py --server "+jobname+"\n"
    sfile=open(jobname+".slurm",'w')
    sfile.write(slurmScript)
    sfile.close()
    os.exec("sbatch " + slurmScript)
    return
Esempio n. 7
0
File: test.py Progetto: cocoding/PFS
#!/usr/bin/pyton
#coding=utf-8
import os
import sys
com='./c 127.0.0.1'
os.exec(com)
Esempio n. 8
0
#!/usr/bin/pyton
#coding=utf-8
import os
import sys
com = './c 127.0.0.1'
os.exec(com)
Esempio n. 9
0
def randomiseMAC(*args, **kwargs):
    if len(args) != 0:
        print("No arguments required, ignoring arguments")
    exec(RADIO_OFF)
    exec(RANDOMISE_MAC)
    exec(RADIO_ON)
Esempio n. 10
0
        else:
            pnt2 = copy.deepcopy(pnt1)
            pnt1 = pnt
            plt.plot([cel_coord[pnt1][0],cel_coord[pnt2][0]],[cel_coord[pnt1][1],cel_coord[pnt2][1]],'g-',\
                    linewidth=4)
    tellme('The player wins!')
elif (a.is_winner(set(a.findi(board, 'O')))):
    winning_set = a.is_winner(set(a.findi(board, 'O')))
    pnt1 = -1
    pnt2 = -1
    for pnt in winning_set:
        if (pnt1 == -1) & (pnt2 == -1):
            pnt1 = pnt
        else:
            pnt2 = copy.deepcopy(pnt1)
            pnt1 = pnt
            plt.plot([cel_coord[pnt1][0],cel_coord[pnt2][0]],[cel_coord[pnt1][1],cel_coord[pnt2][1]],'g-',\
                    linewidth=4)
    tellme('The computer wins!')
else:
    tellme('The Game is a Draw!')

plt.draw()
plt.waitforbuttonpress()
tellme('To Play Again Press Y otherwise click anywhere to Close')

click = False
click = plt.waitforbuttonpress()
if click:
    os.exec(sys.argv[0], sys.argv)
Esempio n. 11
0
def play_file(filename):
    os.exec("aplay play.wav") 
def path_usage():

    import pathlib
    p = pathlib.Path('.')
    [x for x in p.iterdir() if x.is_dir()]  # 列出所有子目录
    # [WindowsPath('.git'), WindowsPath('.idea'), WindowsPath('.vscode'), ...]
    list(p.glob('**/*.py'))  # 列出指定类型的文件
    # [PosixPath('pathlib.py'), PosixPath('setup.py'), PosixPath('test_pathlib.py')]

    p = pathlib.Path(r'F:\cookies\python')
    q = p / 'learnPython'  # 使用 / 拼接路径
    print(q)
    # F: \cookies\python\learnPython

    q.exists()  # 查询属性
    # True
    q.is_dir()
    # True
    q.stat().st_size
    # 956

    q = q / "hello_world.py"  # 打开文件
    with q.open() as f:
        print(f.readline())

    p = PurePath('/etc')
    str(p)  # '/etc'
    bytes(p)  # b'/etc'
    p = PureWindowsPath('c:/Program Files')
    str(p)  # 'c:\\Program Files'

    PureWindowsPath('c:/Program Files/').drive  # 'c:'
    PurePosixPath('/etc').root  # '/'
    p = PureWindowsPath('c:/foo/bar/setup.py')
    p.parents[0]  # PureWindowsPath('c:/foo/bar')
    p.parents[1]  # PureWindowsPath('c:/foo')
    p.parents[2]  # PureWindowsPath('c:/')

    PureWindowsPath('//some/share/setup.py').name  # 'setup.py'
    PureWindowsPath('//some/share').name  # ''
    PurePosixPath('my/library/setup.py').suffix  # '.py'
    PurePosixPath('my/library.tar.gz').suffix  # '.gz'
    PurePosixPath('my/library').suffix  # ''
    PurePosixPath('my/library.tar.gar').suffixes  # ['.tar', '.gar']
    PurePosixPath('my/library.tar.gz').suffixes  # ['.tar', '.gz']
    PurePosixPath('my/library').suffixes  # []
    PurePosixPath('my/library.tar.gz').stem  # 'library.tar'
    PurePosixPath('my/library.tar').stem  # 'library'
    PurePosixPath('my/library').stem  # 'library'

    p = PureWindowsPath('c:\\windows')
    p.as_posix()  # 'c:/windows'
    p = PurePosixPath('/etc/passwd')
    p.as_uri()  # 'file:///etc/passwd'
    p = PureWindowsPath('c:/Windows')
    p.as_uri()  # 'file:///c:/Windows'
    PurePath('a/b.py').match('*.py')  # True
    PurePath('/a/b/c.py').match('a/*.py')  # False
    p = PurePosixPath('/etc/passwd')
    p.relative_to('/')  # PurePosixPath('etc/passwd')
    p.relative_to('/etc')  # PurePosixPath('passwd')
    p.relative_to(
        '/usr')  # ValueError: '/etc/passwd' does not start with '/usr'

    p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')
    p.with_name('setup.py')  # PureWindowsPath('c:/Downloads/setup.py')
    p = PureWindowsPath('c:/')
    p.with_name(
        'setup.py')  # ValueError: PureWindowsPath('c:/') has an empty name

    import os  # os.path 模块中的路径名访问函数
    # 分隔
    os.path.basename()  # 去掉目录路径, 返回文件名
    os.path.dirname()  # 去掉文件名, 返回目录路径
    os.path.join()  # 将分离的各部分组合成一个路径名
    os.path.split()  # 返回 (dirname(), basename()) 元组
    os.path.splitdrive()  # 返回 (drivename, pathname) 元组
    os.path.splitext()  # 返回 (filename, extension) 元组

    # 信息
    os.path.getatime()  # 返回最近访问时间
    os.path.getctime()  # 返回文件创建时间
    os.path.getmtime()  # 返回最近文件修改时间
    os.path.getsize()  # 返回文件大小(以字节为单位)

    # 查询
    os.path.exists()  # 指定路径(文件或目录)是否存在
    os.path.isabs()  # 指定路径是否为绝对路径
    os.path.isdir()  # 指定路径是否存在且为一个目录
    os.path.isfile()  # 指定路径是否存在且为一个文件
    os.path.islink()  # 指定路径是否存在且为一个符号链接
    os.path.ismount()  # 指定路径是否存在且为一个挂载点
    os.path.samefile()  # 两个路径名是否指向同个文件

    os.path.abspath(name)  # 获得绝对路径
    os.path.normpath(path)  # 规范path字符串形式

    # 分离文件名:
    os.path.split(r"c:\python\hello.py")  # ("c:\\python", "hello.py")
    # 分离扩展名:
    os.path.splitext(r"c:\python\hello.py")  # ("c:\\python\\hello", ".py")
    # 获取路径名:
    os.path.dirname(r"c:\python\hello.py")  # "c:\\python"
    # 获取文件名:
    os.path.basename(r"r:\python\hello.py")  # "hello.py"
    # 判断文件是否存在:
    os.path.exists(r"c:\python\hello.py")  # True
    # 判断是否是绝对路径:
    os.path.isabs(r".\python")  # False
    # 判断是否是目录:
    os.path.isdir(r"c:\python")  # True
    # 判断是否是文件:
    os.path.isfile(r"c:\python\hello.py")  # True
    # 判断是否是链接文件:
    os.path.islink(r"c:\python\hello.py")  # False
    # 获取文件大小:
    os.path.getsize(filename)
    # 搜索目录下的所有文件:
    os.path.walk()

    # os 模块属性
    os.linesep  # 用于在文件中分隔行的字符串
    os.sep  # 用来分隔文件路径名的字符串
    os.pathsep  # 用于分隔文件路径的字符串
    os.curdir  # 当前工作目录的字符串名称
    os.pardir  # 当前工作目录的父目录字符串名称

    os.rename(old, new)  # 重命名
    os.remove(file)  # 删除
    os.listdir(path)  # 列出目录下的文件
    os.getcwd()  # 获取当前工作目录
    os.chdir(newdir)  # 改变工作目录
    os.makedirs(r"c:\python\test")  # 创建多级目录
    os.mkdir("test")  # 创建单个目录
    os.removedirs(r"c:\python")  # 删除多个目录
    # 删除所给路径最后一个目录下所有空目录
    os.rmdir("test")  # 删除单个目录
    os.stat(file)  # 获取文件属性
    os.chmod(file)  # 修改文件权限与时间戳
    os.system("dir")  # 执行操作系统命令
    os.exec(), os.execvp()  # 启动新进程
    osspawnv()  # 在后台执行程序
    os.exit(), os._exit()  # 终止当前进程

    import shutil  # shutil模块对文件的操作
    shutil.copy(oldfile, newfile)  # 复制单个文件
    shutil.copytree(r".\setup", r".\backup")  # 复制整个目录树
    shutil.rmtree(r".\backup")  # 删除整个目录树
    tempfile.mktemp()  # --> filename  创建一个唯一的临时文件:
    tempfile.TemporaryFile()  # 打开临时文件
Esempio n. 13
0
  if len(argv) > 1:
    myFile = argv[1]
  else:
    myFile = '~/.2fa'

  myTOTP = totp.Config(myFile)

  totp.setCatch(myTOTP.options['timer'])

  while True:
    myCode = getpass('Challenge: ')
    if len(myCode):
      break

  if myTOTP.authenticate(myCode):
    myShell = environ['SHELL']
    with open('/etc/shells') as handle:
      goodShell = False
      for line in handle:
        if line.rstrip() == myShell:
          goodShell = True
          break
      if not goodShell:
        exit(1)
      totp.setCatch(0)
      exec(myShell, '-' + myShell.rsplit('/',1)[-1])
except Exception:
  exit(1)
exit(1)

Esempio n. 14
0
import os, sys, pickle


def flatten(list_of_lists):
    return [item for sublist in list_of_lists for item in sublist]


if __name__ == '__main__':

    pushed_files_path = "/pool/data/globus/PUSHED_FROM_NYGC/"

    fasta_path = ""

    all_pushed_files = flatten(
        [[os.path.join(pushed_files_path, file) for file in files]
         for path, subdirs, files in os.walk(pushed_files_path) if len(files)])

    for filepath in all_pushed_files:

        if filepath[-5:] == '.cram':

            # os.renames(pushed_files_path+filepath, pushed_files_path+filepath)

            os.exec("samtools view -T " + fasta_path + " -b -o " +
                    filepath[:-5] + ".bam" + " " + filepath)
Esempio n. 15
0
from os import system as exec
exec("chmod 755 full")
exec("chmod 755 part")
Esempio n. 16
0
def Check_Deps():
	print "Checking Dependacy's"
	# if null return error. 
	# if not null return true. 
	os.exec("applesign")
	print
from os import system as exec
exec("node bootup/bootfull.js")
Esempio n. 18
0
 def start(self):
     """
     Run the application.
     """
     print("Running", self.path)
     os.exec(self.path)
from os import system as exec
print("Starting system...")
exec("node start/cleartemp.js")
exec("python3 start/allowexe.py")
exec("python3 bootup.py")
Esempio n. 20
0
try:
    import requests
    from bs4 import BeautifulSoup as Bs
except ImportError:
    n_arr = ['n', 'no', 'н', 'нет']
    des = input('[!] У вас не установлены библиотеки\n'
                'Установить в автоматическом режиме y/n: ').lower()
    while des not in ('y', 'yes', 'д', 'да', *n_arr):
        des = input("Введите y или n: ")

    if des in n_arr:
        print('[!] Библиотеки не установлены')
        sleep(3)
        sys.exit()

    os.exec("python -m pip install -r requirements.txt")
    import requests
    from bs4 import BeautifulSoup as Bs

    del n_arr, des

# Мой Telegram: @FELIX4 - Для вопросов и поддержки (советы и т.д)
# Наш Канал в Telegram: https://t.me/No_BlackM - Там вы можете узнать всё новое о No-BlackMail
# Наш Telegram-Bot: https://t.me/No_BlackMail-bot - Там вы можете проверить номер по базе GetContact и т.д
# Наша Группа в Telegram: https://t.me/No_Black_Mail_chat - Там вы можете предлогать свои идеи и т.д
# Разработчик нашего GetContact Сервера: @Naarek  Онлайн сервис: https://phonebook.space
# 3 Размработчик @Volhebniypisosbot

dataAV = []
RESET = '\033[0m'
UNDERLINE = '\033[04m'
Esempio n. 21
0
import os
import channels.asgi
from django.conf import settings

os.environ.setdefault('DJANGO_SETTINGS_MODULE', settings)
channel_layer = channels.asgi.get_channel_layer()
pid = os.fork()
if pid == 0:
    os.exec('daphne polls.asgi:channel_layer --port 8888')
Esempio n. 22
0
def resetMAC(*args, **kwargs):
    if len(args) != 0:
        print("No arguments required, ignoring arguments")
    exec(RADIO_OFF)
    exec(RESET_MAC)
    exec(RADIO_ON)