bloomberg / phabricator-tools

Phabricator Tools
Apache License 2.0
219 stars 46 forks source link

Make arcyon Windows compatible #15

Open jgr3go opened 9 years ago

jgr3go commented 9 years ago

When trying to run arcyon on a Windows environment, you get the error:

$ arcyon
Traceback (most recent call last):
  File "c:/Program Files/arcanist/phabricator-tools/bin/arcyon", line 31, in <module>
    import aoncmd_arcyon  # noqa
  File "c:\Program Files\arcanist\phabricator-tools\py\aon\aoncmd_arcyon.py", line 33, in <module>
    import aoncmd_gitdiffhelper
  File "c:\Program Files\arcanist\phabricator-tools\py\aon\aoncmd_gitdiffhelper.py", line 31, in <module>
    import abdt_branch
  File "c:\Program Files\arcanist\phabricator-tools\py\abd\abdt_branch.py", line 61, in <module>
    import abdt_differ
  File "c:\Program Files\arcanist\phabricator-tools\py\abd\abdt_differ.py", line 32, in <module>
    import phlgit_diff
  File "c:\Program Files\arcanist\phabricator-tools\py\phl\phlgit_diff.py", line 26, in <module>
    import phlsys_fs
  File "c:\Program Files\arcanist\phabricator-tools\py\phl\phlsys_fs.py", line 33, in <module>
    import fcntl
ImportError: No module named fcntl

It seems that fcntl is used to get file lock permissions, but no fcntl module exists for Windows. It's worth noting that arcanist uses the EDITOR config variable to get blocking sessions (PhutilInteractiveEditor.php) so it is possible, just not with the fcntl module.

Worth noting, I have no idea if this is the only code that's not Windows compatible, so this request may be more than just what I've listed here.

flippingtables commented 8 years ago

I found a fix for this. Create a file called 'fcntl.py' and put it in the py/phl/ directory. Paste this code in the file:

def fcntl(fd, op, arg=0):
    return 0

def ioctl(fd, op, arg=0, mutable_flag=True):
    if mutable_flag:
        return 0
    else:
        return ""

def flock(fd, op):
    return

def lockf(fd, operation, length=0, start=0, whence=0):
    return
aevri commented 8 years ago

Maybe we should split out the platform-dependent bits of phlsys_fs into their own module, perhaps called phlsys_fsunix or similar. That way we would still get errors if we try to use unimplemented functionality, arcyon probably doesn't need to use phlsys_fsunix and would then work on Windows.