Skip to content

Commit

Permalink
Merge pull request #370 from jburel/portalocker
Browse files Browse the repository at this point in the history
Replace Portalocker
  • Loading branch information
jburel authored Sep 6, 2023
2 parents 76d7048 + f11d362 commit 273c275
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 555 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
include:
- python-version: '3.8'
os: macos-latest
- python-version: '3.7'
- python-version: '3.8'
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def read(fname):
'PyYAML',
'zeroc-ice>=3.6.5,<3.7',
'pywin32; platform_system=="Windows"',
'requests'
'requests',
'portalocker'
],
tests_require=[
'pytest',
Expand Down
2 changes: 1 addition & 1 deletion src/omero/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
XML, Element, ElementTree, SubElement, Comment, tostring
)
import omero_ext.path as path
from omero_ext import portalocker
import portalocker
import json


Expand Down
7 changes: 3 additions & 4 deletions src/omero/hdfstorageV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from omero.rtypes import rfloat, rlong, rstring, unwrap
from omero.util.decorators import locked
from omero_ext.path import path
from omero_ext import portalocker
import portalocker
from functools import wraps


Expand Down Expand Up @@ -134,11 +134,10 @@ def addOrThrow(self, hdfpath, hdfstorage, read_only=False):
mode = read_only and "r" or "a"
hdffile = hdfstorage.openfile(mode)
fileno = hdffile.fileno()

if not read_only:
try:
portalocker.lockno(
fileno, portalocker.LOCK_NB | portalocker.LOCK_EX)
portalocker.lock(
hdffile, flags=(portalocker.LOCK_NB | portalocker.LOCK_EX))
except portalocker.LockException:
hdffile.close()
raise omero.LockTimeout(
Expand Down
2 changes: 1 addition & 1 deletion src/omero/plugins/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
WriteableConfigControl, with_config
from omero.install.windows_warning import windows_warning, WINDOWS_WARNING

from omero_ext import portalocker
import portalocker
from omero_ext.path import path
from omero_ext.which import whichall
from omero_ext.argparse import FileType
Expand Down
2 changes: 1 addition & 1 deletion src/omero/plugins/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from omero.util import edit_path, get_omero_userdir
from omero.util.decorators import wraps
from omero.util.upgrade_check import UpgradeCheck
from omero_ext import portalocker
import portalocker
from omero_ext.argparse import SUPPRESS
from omero_ext.path import path

Expand Down
6 changes: 3 additions & 3 deletions src/omero/util/temp_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import tempfile

from omero.util import get_omero_userdir, get_user
from omero_ext import portalocker
import portalocker
from omero_ext.path import path

# Activating logging at a static level
Expand Down Expand Up @@ -241,8 +241,8 @@ def create(self, dir):
If the given directory doesn't exist, creates it (with mode 0700)
and returns True. Otherwise False.
"""
dir = path(dir)
if not dir.exists():
# dir = path(dir)
if not os.path.exists(dir):
dir.makedirs(0o700)
return True
return False
Expand Down
Loading

0 comments on commit 273c275

Please sign in to comment.