Skip to content

Commit

Permalink
cameractrlsd: move find_symlink_in to cameractrls
Browse files Browse the repository at this point in the history
  • Loading branch information
soyersoyer committed Apr 11, 2024
1 parent 1f32cca commit bd53500
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 9 additions & 0 deletions cameractrls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,15 @@ def save_preset(self, device, preset_num, errs):
except Exception as e:
collect_warning(f'ConfigPreset: save_preset failed: {e}', errs)

def find_symlink_in(dir, paths):
for path in paths:
if not os.path.isdir(path):
continue
for p in os.scandir(path):
if p.is_symlink() and os.path.realpath(p) == dir:
return p
return None

def get_configdir():
return os.getenv("XDG_CONFIG_HOME", os.path.expanduser('~/.config/hu.irl.cameractrls'))

Expand Down
11 changes: 1 addition & 10 deletions cameractrlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys, os, ctypes, ctypes.util, logging, getopt, time
from collections import namedtuple
from struct import unpack_from, calcsize
from cameractrls import CameraCtrls, get_configfilename
from cameractrls import CameraCtrls, find_symlink_in, get_configfilename

clib = ctypes.util.find_library('c')
if clib is None:
Expand Down Expand Up @@ -114,15 +114,6 @@ def parse_events(data):
events.append(Event(wd, mask, cookie, namesize, name.decode()))
return events

def find_symlink_in(dir, paths):
for path in paths:
if not os.path.isdir(path):
continue
for p in os.scandir(path):
if p.is_symlink() and os.path.realpath(p) == dir:
return p
return None

def main():
try:
arguments, values = getopt.getopt(sys.argv[1:], 'h', ['help'])
Expand Down

0 comments on commit bd53500

Please sign in to comment.