0

The python file name is orientationplot.py This file is very easy to find by google. This python script is used for visualizing the behavior of the WindowOrientationListener in android. but it is write for linux. I want to use it in windows. but there is a error, how can I make this file run in windows.

Traceback (most recent call last):
  File "G:\perftool\orientationplot\orientationplot.py", line 27, in <module>
    import fcntl
ImportError: No module named fcntl
fcntl.fcntl(stream, fcntl.F_SETFL, os.O_NONBLOCK)
Bakuriu
  • 98,325
  • 22
  • 197
  • 231

1 Answers1

1

You definitely cannot simply rewrite this program for Windows. It makes heavy use of the fcntl module. If you aren't aware, fcntl is a system call on Linux that manipulates file descriptors.

fcntl.fcntl(stream, fcntl.F_SETFL, os.O_NONBLOCK)

nosklo wrote in this StackOverflow answer:

The substitute of fcntl on windows are win32api calls. The usage is completely different. It is not some switch you can just flip.

I do want to point out, though, that with some research this is probably possible. You need to figure out how to set the file descriptor flags of a stream in Windows (that is, the stream's permissions and other flags specified by the open() system call), and setting os.O_NONBLOCK. I found some more information on the Winsock website:

The Unix fcntl() call has no direct equivalent under Winsock. Where necessary, similar functionality exists in Winsock’s ioctlsocket() call. For example, the equivalent of using Unix’s fcntl() to set a socket’s O_NONBLOCK flag is setting the FIONBIO flag with Winsock’s ioctlsocket().

Community
  • 1
  • 1
Fredrick Brennan
  • 7,079
  • 2
  • 30
  • 61