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