Пример #1
0
def main():
    global bootstrap_path

    if len(sys.argv) < 2:
        print("Expected execution: chroot <path_to_root_fs> python3 sock2.py <path_to_bootstrap.py> [cgroup-count]")
        print("    cgroup-count: number of FDs (starting at 3) that refer to /sys/fs/cgroup/..../cgroup.procs files")
        sys.exit(1)

    print('sock2.py: started new process with args: ' + " ".join(sys.argv))

    bootstrap_path = sys.argv[1]
    cgroup_fds = 0
    if len(sys.argv) > 2:
        cgroup_fds = int(sys.argv[2])

    # join cgroups passed to us.  The fact that chroot is called
    # before we start means we also need to pass FDs to the cgroups we
    # want to join, because chroot happens before we run, so we can no
    # longer reach them by paths.
    pid = str(os.getpid())
    for i in range(cgroup_fds):
        # golang guarantees extras start at 3: https://golang.org/pkg/os/exec/#Cmd
        fd = 3 + i
        f = os.fdopen(fd, "w")
        f.write(pid)
        print('sock2.py: joined cgroup, close FD %d' % fd)
        f.close()

    start_container()
Пример #2
0
 def test_vtk(self, request, tmp_path, ref_path, update,
              patch_execution_stamp, patch_datetime_now, output, fname,
              inc):
     result = Result(ref_path / fname).view('increments', inc)
     os.chdir(tmp_path)
     result.save_VTK(output)
     fname = fname.split(
         '.')[0] + f'_inc{(inc if type(inc) == int else inc[0]):0>2}.vtr'
     last = ''
     for i in range(10):
         if os.path.isfile(tmp_path / fname):
             with open(fname) as f:
                 cur = hashlib.md5(f.read().encode()).hexdigest()
                 if cur == last:
                     break
                 else:
                     last = cur
         time.sleep(.5)
     if update:
         with open((ref_path / 'save_VTK' /
                    request.node.name).with_suffix('.md5'), 'w') as f:
             f.write(cur)
     with open((ref_path / 'save_VTK' /
                request.node.name).with_suffix('.md5')) as f:
         assert cur == f.read()
Пример #3
0
 def test_vtk(self, request, tmp_path, ref_path, update,
              patch_execution_stamp, patch_datetime_now, output, fname,
              inc):
     result = Result(ref_path / fname).view(increments=inc)
     os.chdir(tmp_path)
     result.export_VTK(output, parallel=False)
     fname = fname.split(
         '.')[0] + f'_inc{(inc if type(inc) == int else inc[0]):0>2}.vti'
     v = VTK.load(tmp_path / fname)
     v.set_comments('n/a')
     v.save(tmp_path / fname, parallel=False)
     with open(fname) as f:
         cur = hashlib.md5(f.read().encode()).hexdigest()
     if update:
         with open((ref_path / 'export_VTK' /
                    request.node.name).with_suffix('.md5'), 'w') as f:
             f.write(cur + '\n')
     with open((ref_path / 'export_VTK' /
                request.node.name).with_suffix('.md5')) as f:
         assert cur == f.read().strip('\n')
Пример #4
0
def auth():
    
    #convert Users to a list
    User_file = open('Users', 'r')
    User_lines = User_file.readlines()
    User_file.close()
    
    #convert PassHash to a list
    PassHash_file = open('PassHash', 'r')
    PassHash_lines = PassHash_file.readlines()
    PassHash_file.close()


    while True:
        try:
            
            User = input("Username:  "******"Incorrect Password")
                print()
            
            
            
        except(ValueError):
            print()
            print("Incorrect Username")
            print()