mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 19:52:16 +00:00
Remove remaining traces of Python 2
This commit is contained in:
parent
078c98a427
commit
6f26493c11
@ -10,7 +10,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import cmd
|
import cmd
|
||||||
import getpass
|
import getpass
|
||||||
import pipes # replace by shlex once Python 2.7 supprt is dropped
|
|
||||||
import shlex
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@ -424,7 +423,7 @@ def main():
|
|||||||
|
|
||||||
cli = SupysonicCLI(config)
|
cli = SupysonicCLI(config)
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
cli.onecmd(" ".join(pipes.quote(arg) for arg in sys.argv[1:]))
|
cli.onecmd(" ".join(shlex.quote(arg) for arg in sys.argv[1:]))
|
||||||
else:
|
else:
|
||||||
cli.cmdloop()
|
cli.cmdloop()
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ class DaemonClient(object):
|
|||||||
c.send(ScannerStartCommand(folders, force))
|
c.send(ScannerStartCommand(folders, force))
|
||||||
|
|
||||||
def jukebox_control(self, action, *args):
|
def jukebox_control(self, action, *args):
|
||||||
if not isinstance(action, strtype):
|
if not isinstance(action, str):
|
||||||
raise TypeError("Expecting string, got " + str(type(action)))
|
raise TypeError("Expecting string, got " + str(type(action)))
|
||||||
with self.__get_connection() as c:
|
with self.__get_connection() as c:
|
||||||
c.send(JukeboxCommand(action, args))
|
c.send(JukeboxCommand(action, args))
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
# Distributed under terms of the GNU AGPLv3 license.
|
# Distributed under terms of the GNU AGPLv3 license.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import shlex
|
import shlex
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from pony.orm import db_session, ObjectNotFound
|
from pony.orm import db_session, ObjectNotFound
|
||||||
from random import shuffle
|
from random import shuffle
|
||||||
from subprocess import Popen
|
from subprocess import Popen, DEVNULL
|
||||||
from threading import Thread, Event, RLock
|
from threading import Thread, Event, RLock
|
||||||
|
|
||||||
from .db import Track
|
from .db import Track
|
||||||
@ -31,8 +30,6 @@ class Jukebox(object):
|
|||||||
self.__offset = 0
|
self.__offset = 0
|
||||||
self.__start = None
|
self.__start = None
|
||||||
|
|
||||||
self.__devnull = None
|
|
||||||
|
|
||||||
self.__thread = None
|
self.__thread = None
|
||||||
self.__lock = RLock()
|
self.__lock = RLock()
|
||||||
self.__skip = Event()
|
self.__skip = Event()
|
||||||
@ -51,18 +48,6 @@ class Jukebox(object):
|
|||||||
return 0
|
return 0
|
||||||
return int((datetime.utcnow() - self.__start).total_seconds())
|
return int((datetime.utcnow() - self.__start).total_seconds())
|
||||||
|
|
||||||
# subprocess.DEVNULL doesn't exist on Python 2.7
|
|
||||||
def _get_devnull(self):
|
|
||||||
if self.__devnull is None:
|
|
||||||
self.__devnull = os.open(os.devnull, os.O_RDWR)
|
|
||||||
return self.__devnull
|
|
||||||
|
|
||||||
def _close_devnull(self):
|
|
||||||
if self.__devnull is None:
|
|
||||||
return
|
|
||||||
os.close(self.__devnull)
|
|
||||||
self.__devnull = None
|
|
||||||
|
|
||||||
def set(self, *tracks):
|
def set(self, *tracks):
|
||||||
self.clear()
|
self.clear()
|
||||||
self.add(*tracks)
|
self.add(*tracks)
|
||||||
@ -157,7 +142,6 @@ class Jukebox(object):
|
|||||||
|
|
||||||
proc.terminate()
|
proc.terminate()
|
||||||
proc.wait()
|
proc.wait()
|
||||||
self._close_devnull()
|
|
||||||
self.__start = None
|
self.__start = None
|
||||||
|
|
||||||
def __play_file(self):
|
def __play_file(self):
|
||||||
@ -172,12 +156,7 @@ class Jukebox(object):
|
|||||||
|
|
||||||
logger.debug("Start playing with command %s", args)
|
logger.debug("Start playing with command %s", args)
|
||||||
try:
|
try:
|
||||||
return Popen(
|
return Popen(args, stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL)
|
||||||
args,
|
|
||||||
stdin=self._get_devnull(),
|
|
||||||
stdout=self._get_devnull(),
|
|
||||||
stderr=self._get_devnull(),
|
|
||||||
)
|
|
||||||
except:
|
except:
|
||||||
logger.exception("Failed running play command")
|
logger.exception("Failed running play command")
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user