小编Con*_*Guo的帖子

创建一个没有挂载的虚拟软盘映像?

要显示创建虚拟软盘映像文件作为超级用户或用户可以运行sudo命令,有很多帖子.基本步骤是:

  1. dd命令创建空的1.44MB图像文件
  2. 格式化图像文件 mkfs.msdos
  3. 将映像文件挂载到某个挂载点
  4. 将某些内容复制到挂载点
  5. umount 虚拟软盘映像文件

我的问题是,如果我只是一个无法运行sudo命令的普通用户,我如何按照上述步骤创建虚拟软盘映像并在其中写入内容?

非常感谢.

linux sudo mount dd floppy

12
推荐指数
1
解决办法
1万
查看次数

如何通过`pstree`获取所有父进程和所有子进程

命令pstree PID可以显示由指定的进程的所有子进程信息PID.但是,我也想了解该过程的所有父进程信息,PID我该如何获得它?

举个例子,给出以下过程:

init
|- parent_process
|    `- current_process
|       |- subprocess_1
|       `- subprocess_2
`- other_process

我想要的是当我跑步时pstree current_process_pid,我想要低于输出

init
`- parent_process
    `- current_process
       |- subprocess_1
       `- subprocess_2

当我跑pstree subprocess_1_pid,它会输出

init
`- parent_process
    `- current_process
       `- subprocess_1

提前致谢

linux shell command-line

12
推荐指数
2
解决办法
2万
查看次数

当正常输出和异常混合在一起时 Doctest 失败?

是否doctest支持输出和异常混合在一起?

一个例子是:

>>> def foo():
...    print 'hello world!'
>>> foo()
hello world!
>>> def bar():
...     raise Exception()
>>> bar()
Traceback (most recent call last):
    ...
Exception

>>> def foo_bar():
...     foo()
...     bar()
>>> foo_bar()
hello world!
Traceback (most recent call last):
    ...
Exception
Run Code Online (Sandbox Code Playgroud)

我预计这三个案例都会成功,但只有其中两个成功,请参阅

$ python -m doctest -v /tmp/1.py
Trying:
    def foo():
       print 'hello world!'
Expecting nothing
ok
Trying:
    foo()
Expecting:
    hello world!
ok
Trying:
    def bar():
        raise Exception()
Expecting nothing
ok
Trying:
    bar() …
Run Code Online (Sandbox Code Playgroud)

python testing doctest

5
推荐指数
1
解决办法
369
查看次数

标签 统计

linux ×2

command-line ×1

dd ×1

doctest ×1

floppy ×1

mount ×1

python ×1

shell ×1

sudo ×1

testing ×1