我正在尝试为我正在使用 python 3.3.4 和 PyQt4 编写的 GUI 应用程序获取旋转日志文件。
我的主脚本中有以下代码片段:
import logging
import resources
logger = logging.getLogger('main.test')
def main():
logger.setLevel(logging.DEBUG)
fh = RotatingFileHandler(resources.LOG_FILE_PATH, maxBytes=500, backupCount=5)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
logger.addHandler(fh)
logger.info('main')
Run Code Online (Sandbox Code Playgroud)
我的 maxBytes 很低,以便我可以测试旋转是否正常工作,但事实并非如此。每当应该轮换日志时,我都会收到以下错误:
Traceback (most recent call last):
File "C:\Python33\lib\logging\handlers.py", line 73, in emit
self.doRollover()
File "C:\Python33\lib\logging\handlers.py", line 176, in doRollover
self.rotate(self.baseFilename, dfn)
File "C:\Python33\lib\logging\handlers.py", line 116, in rotate
os.rename(source, dest)
PermissionError: [WinError 32] The process cannot access the file because it is being …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个扫描蓝牙耳机的简单程序(我正在使用PS3耳机进行测试),然后连接到它.我正在使用蓝牙聊天程序示例中的代码.但是,我不能让它连接到任何东西.当它到达connect()时它给我一个I/O异常.
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
Run Code Online (Sandbox Code Playgroud)
尝试与设备建立传出连接时,此线程会运行.它直接通过; 连接成功或失败.
private class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
public ConnectThread(BluetoothDevice device) {
mmDevice = device;
BluetoothSocket tmp = null;
// Get a BluetoothSocket for a connection with the given BluetoothDevice
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
Log.e(TAG, "create() failed", e);
}
if (tmp == null){
Log.i(TAG, "tmp is NULL");
}
mmSocket = tmp;
}
public void run() { …Run Code Online (Sandbox Code Playgroud) 我已经下载了google默认主屏幕和adw的源代码.我在Eclipse中创建了一个项目并使用了这些源代码.但是,由于存在相当多的错误,我无法编译代码.有谁知道如何正确地做到这一点?我是否需要将所有Google代码添加到我的项目中?(我在另一个帖子中问了同样的问题,链接文字)
谢谢