Giter Site home page Giter Site logo

audioautotest's People

Contributors

hw-lee avatar yixuanjiang-tw avatar

Watchers

 avatar  avatar

Forkers

htcaudiotool

audioautotest's Issues

[Capability] libs api on win

In audiofunction.py

class ToneDetectorForDeviceThread(ToneDetectorThread):
    def __init__(self, serialno, target_freq, callback):
        super(ToneDetectorForDeviceThread, self).__init__(target_freq=target_freq, callback=callback)
        self.serialno = serialno

    ............

    def run(self):
        LogcatListener.init(self.serialno)

    ............

        while not self.stoprequest.isSet():
            os.system("adb -s {} shell am broadcast -a audio.htc.com.intent.print.properties > /dev/null".format(self.serialno))
            # TODO: it seems that the Adb APIs probably should not be called constantly during a short period
            #       therefore, using the primary os.system is preferred currently
            # Adb.execute(cmd=["shell", "am", "broadcast", "-a", "audio.htc.com.intent.print.properties"], serialno=self.serialno, tolog=False)
            time.sleep(0.01)

        LogcatListener.unregister_event(serialno=self.serialno, logcat_event=logcat_event)

The windows does not have /dev/null.

In logcatlistener.py

class LogcatOutputThread(threading.Thread):
    def __init__(self, serialno):
        super(LogcatOutputThread, self).__init__()
        self.serialno = serialno
        self.daemon = True
        self.msg_q = queue.Queue()
        self.listeners = {}
        self.stoprequest = threading.Event()
        self.proc = None

    ............

    def run(self):
        self.proc = subprocess.Popen(["adb", "-s", self.serialno, "logcat"], stdout=subprocess.PIPE, preexec_fn=os.setsid)
        while not self.stoprequest.isSet():
            if self.proc.poll() != None:
                break

            line = self.proc.stdout.readline()
            self._handle_logcat_msg(line)

        os.killpg(os.getpgid(self.proc.pid), signal.SIGTERM)

The python does not support os.setsid in windows.

In ssr_test.py

def push_files_if_needed(serialno):
    out, _ = Adb.execute(cmd=["shell", "ls", DEVICE_MUSIC_DIR], serialno=serialno)

    # The command "adb shell ls" might return several lines of strings where each line lists multiple file names
    # Then the result should be handled line by line:
    #           map function for split with spaces and reduce function for concatenate the results of each line
    files = reduce(lambda x, y: x+y, map(lambda s: s.split(), out.splitlines())) if out else []

    for file_to_pushed in FILE_NAMES:
        if file_to_pushed in files:
            continue
        out, _ = subprocess.Popen(["find", ROOT_DIR, "-name", file_to_pushed], stdout=subprocess.PIPE).communicate()
        file_path = out.splitlines()[0] if out else None
        if file_path:
            os.system("adb -s {} push {} {} > /dev/null".format(serialno, file_path, DEVICE_MUSIC_DIR))
        else:
            raise ValueError("Cannot find the file \"{}\", please place it under the project tree.".format(file_to_pushed))

The linux command find is different from that in windows.

 out, _ = subprocess.Popen(["find", ROOT_DIR, "-name", file_to_pushed], stdout=subprocess.PIPE).communicate()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.