PHP 8.2.30
Preview: flock_tool.py Size: 1.71 KB
/proc/thread-self/root/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py

#! /usr/bin/python2
# Copyright (c) 2011 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""These functions are executed via gyp-flock-tool when using the Makefile
generator.  Used on systems that don't have a built-in flock."""

import fcntl
import os
import struct
import subprocess
import sys


def main(args):
  executor = FlockTool()
  executor.Dispatch(args)


class FlockTool(object):
  """This class emulates the 'flock' command."""
  def Dispatch(self, args):
    """Dispatches a string command to a method."""
    if len(args) < 1:
      raise Exception("Not enough arguments")

    method = "Exec%s" % self._CommandifyName(args[0])
    getattr(self, method)(*args[1:])

  def _CommandifyName(self, name_string):
    """Transforms a tool name like copy-info-plist to CopyInfoPlist"""
    return name_string.title().replace('-', '')

  def ExecFlock(self, lockfile, *cmd_list):
    """Emulates the most basic behavior of Linux's flock(1)."""
    # Rely on exception handling to report errors.
    # Note that the stock python on SunOS has a bug
    # where fcntl.flock(fd, LOCK_EX) always fails
    # with EBADF, that's why we use this F_SETLK
    # hack instead.
    fd = os.open(lockfile, os.O_WRONLY|os.O_NOCTTY|os.O_CREAT, 0o666)
    if sys.platform.startswith('aix'):
      # Python on AIX is compiled with LARGEFILE support, which changes the
      # struct size.
      op = struct.pack('hhIllqq', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
    else:
      op = struct.pack('hhllhhl', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
    fcntl.fcntl(fd, fcntl.F_SETLK, op)
    return subprocess.call(cmd_list)


if __name__ == '__main__':
  sys.exit(main(sys.argv[1:]))

Directory Contents

Dirs: 1 × Files: 25

Name Size Perms Modified Actions
generator DIR
- drwxr-xr-x 2024-03-03 22:36:29
Edit Download
20.58 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
1.92 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
4.87 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
3.25 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
1.71 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
113.65 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
3.11 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
22.89 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
11.66 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
6.24 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
44.11 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
64.56 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
1.76 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
4.97 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
9.31 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
17.02 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
46.76 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
5.41 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
1.30 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
12.72 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
117.66 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
64.85 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
10.32 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
2.12 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download
21.87 KB lrw-r--r-- 2021-03-10 14:36:38
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).