在Windows 7计算机上,我使用以下命令从本地目录安装软件包:
pip install addons/pnc_tests --upgrade --extra-index-url=http://some_server/simple
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
C:\Users\alex\PNC\tas\ENV\Scripts\pip-script.py run on 07/16/14 07:50:47
Exception:
Traceback (most recent call last):
File "C:\Users\alex\PNC\tas\ENV\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Users\alex\PNC\tas\ENV\lib\site-packages\pip\commands\install.py", line 258, in run
InstallRequirement.from_line(name, None))
File "C:\Users\alex\PNC\tas\ENV\lib\site-packages\pip\req.py", line 173, in from_line
return cls(req, comes_from, url=url, prereleases=prereleases)
File "C:\Users\alex\PNC\tas\ENV\lib\site-packages\pip\req.py", line 71, in __init__
req = pkg_resources.Requirement.parse(req)
File "C:\Users\alex\PNC\tas\ENV\lib\site-packages\pip\_vendor\pkg_resources.py", line 2667, in parse
reqs = list(parse_requirements(s))
File "C:\Users\alex\PNC\tas\ENV\lib\site-packages\pip\_vendor\pkg_resources.py", line 2605, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "C:\Users\alex\PNC\tas\ENV\lib\site-packages\pip\_vendor\pkg_resources.py", …Run Code Online (Sandbox Code Playgroud) 请考虑以下echo命令:
echo -e "at\r"
Run Code Online (Sandbox Code Playgroud)
它at在命令行上产生输出,即\ r \n特殊字符已被解释.我想用文件中的一些文本做同样的事情.假设完全相同的序列
at\r
Run Code Online (Sandbox Code Playgroud)
写入一个名为的文件at.txt,然后我想在终端上显示它.但
cat at.txt
Run Code Online (Sandbox Code Playgroud)
给出输出
at\r
Run Code Online (Sandbox Code Playgroud)
什么不是我想要的.我希望解释特殊序列\ r \n,而不仅仅是在终端上打印.有人有什么想法?
谢谢Alex
我有以下测试代码检查函数中的异常引发.我希望测试通过,但是会指示失败.这是测试代码:
import unittest
# define a user-defined exception
class MyException(Exception):
def __str__(self):
return repr("ERROR: Just raised my exception!")
# this is my main class with a method raising this exception
class MyMainObject(object):
def func(self):
raise MyException()
# the test class
class TestConfig(unittest.TestCase):
def test_1(self):
other = MyMainObject()
self.assertRaises(MyException, other.func())
# calling the test
if __name__ == '__main__':
unittest.main()
Run Code Online (Sandbox Code Playgroud)
当other.func()被调用的断言语句,MyException提高(可以容易地检查).因此,assertRaises测试应该通过测试,因为other.func()与...相关MyException,但是:
....
MyException: 'ERROR: Just raised my exception!'
----------------------------------------------------------------------
Ran 1 test …Run Code Online (Sandbox Code Playgroud) 我正在研究一个在gentoo Linux上运行的非常大而复杂的PHP项目,这显然存在PHP信号量的一些问题.由于项目的规模和复杂性,我无法发布代码.我也无法提供再现问题的工作示例.它可能是由程序的复杂性以非威慑方式引起的.
问题出在这里:PHP代码正在尝试使用信号量写入和读取共享内存.在产生问题的情况下,执行以下操作:
在时间006.68,PHP 4.4.9执行以下代码,将5个字节的数据写入共享内存,$iVarKey其值为2010147023
sem_acquire($this->rSemaphore);
shm_put_var($this->rShm, $iVarKey, $mVar);
sem_release($this->rSemaphore);
Run Code Online (Sandbox Code Playgroud)
此操作在006.69时结束
在时间006.77,PHP 5.2.10执行以下代码,从共享内存中读取5个字节的数据,$iVarKey其值为622679600:
sem_acquire($this->rSemaphore);
$mVar = shm_get_var($this->rShm,$iVarKey);
sem_release($this->rSemaphore);
Run Code Online (Sandbox Code Playgroud)
此操作在006.78时结束
在时间016.01以下代码是由PHP 5.2.10(的代码相同的行中#2)执行,以从共享存储器读出5个字节的数据,以$iVarKey具有值2010147023(同#1):
sem_acquire($this->rSemaphore);
$mVar = shm_get_var($this->rShm,$iVarKey);
sem_release($this->rSemaphore);
Run Code Online (Sandbox Code Playgroud)
此操作现在大约需要2分钟,尽管具有相同的资源/信号量$iVarKey已提前约10秒发布.在此期间没有访问共享内存,因为我已经确定了每次调用sem_acquire!
如何sem_acquire阻止程序执行,尽管它不应该.也许这是版本4.4.9/5.2.10中的错误?有没有人看起来像类似的东西?有解决方法吗?我可以做些什么来进一步投资这个问题吗?
我真的很感激这个问题的帮助!
备注:
附加信息: - 我已经检查过每次通话sem_release,但似乎没有人回复FALSE.因此,我的问题并非来自失败的释放.- 当系统阻塞时,ipcs -s返回以下输出,与系统未阻塞时相同
------ Semaphore Arrays --------
key semid owner perms nsems
0x000f4240 0 root 666 3
0x00000001 32769 root 666 3
0x00000000 65538 apache 600 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用python-selenium API(版本2.53.6)在不同的浏览器上执行GUI测试.当我尝试以下列方式使用IE(11.0.10240)时(Windows Server 2012 R2 Standard,64bit); 使用身份验证
driver = webdriver.Ie()
driver.get("http://user:password@my.test.server.com")
Run Code Online (Sandbox Code Playgroud)
然后我收到以下错误消息:
selenium.common.exceptions.WebDriverException: Message: Failed to navigate to http://user:password@my.test.server.com. This usually means that a call to the COM method IWebBrowser2::Navigate2() failed.
Run Code Online (Sandbox Code Playgroud)
有没有办法解决这个错误?
附录:
我在非公共网页上运行非常复杂的python-selenium测试.在大多数情况下,这些测试运行良好,但有时其中一个测试在webdriver本身初始化期间失败.
提示:尝试初始化webdriver时会发生此错误,即执行以下操作时:
# Start of the tests
mydriver = webdriver.Firefox(firefox_profile=profile, log_path=logfile)
# ERROR HAPPENS HERE
# Doing other stuff here
....
# Doing tests here
....
# Doing shutdown here
mydriver.quit()
Run Code Online (Sandbox Code Playgroud)
以下是此类错误的完整示例:
___________ ERROR at setup of TestSuite.test_synaptic_events_fitting ___________
> lambda: ihook(item=item, **kwds),
when=when,
)
/usr/local/lib/python2.7/dist-packages/flaky/flaky_pytest_plugin.py:273:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ …Run Code Online (Sandbox Code Playgroud) 我正在创建一个ipywidget带有一些文本的按钮。但是按钮中没有显示全文:
我使用的代码如下:
import ipywidgets as widgets
from IPython.display import display
button = widgets.Button(
description='Test button with some text.',
disabled=False,
display='flex',
flex_flow='column',
align_items='stretch'
)
display(button)
Run Code Online (Sandbox Code Playgroud)
使用什么选项才能在按钮中显示全文(即使按钮宽度增加以显示全文)?
我有一个我无法发布的复杂软件,也没有具体的工作示例.我会尝试解释这个问题,也许有人曾经遇到过这个问题.
在Linux shell上我定义了一个环境变量:
> export MY_TEST_ENV=4711
> echo $MY_TEST_ENV
> 4711
Run Code Online (Sandbox Code Playgroud)
在复杂的代码中我想用这个变量获取
print os.getenv('MY_TEST_ENV')
Run Code Online (Sandbox Code Playgroud)
总是回来None.如果我创建一个测试脚本来测试这种行为,即使是不同文件中的类,我总是得到所需的行为,例如,os.getenv('MY_TEST_ENV')返回正确的值4711.
代码以sudo.开头.
任何想法可能是什么原因?
在Ubuntu 12.04上,我想通过以下命令获取管理值的子树:
snmpwalk -v 2c -c public localhost
Run Code Online (Sandbox Code Playgroud)
输出的最后一行是
iso.3.6.1.2.1.25.1.7.0 = No more variables left in this MIB View (It is past the end of the MIB tree)
Run Code Online (Sandbox Code Playgroud)
这是一个错误吗?一个警告?子树结束了吗?
我有一个复杂的python(2.7.3)脚本,试图通过打开套接字连接
self.socket.close()
# doing something else
self.socket.connect((host, port))
Run Code Online (Sandbox Code Playgroud)
但我得到的是以下套接字错误:
error: [Errno 9] Bad file descriptor
Run Code Online (Sandbox Code Playgroud)
在host:port我已经验证了这一点与接受连接nc host port手动.那么我可能会因为打开与给定端口的连接而出现此错误的原因是什么呢?
我不能也不会发布完整的脚本,因为这个问题太复杂和无关紧要.我只是想知道这个错误的所有可能原因,以及如何检查和修复它们.
python ×7
linux ×3
selenium ×2
cat ×1
echo ×1
escaping ×1
firefox ×1
geckodriver ×1
getenv ×1
ipywidgets ×1
php ×1
python-2.7 ×1
semaphore ×1
snmp ×1
sockets ×1
ubuntu ×1
unit-testing ×1
windows ×1