示例#1
0
 def start_record(self):
     """
     Begins dumping the configured stream to disk.
     """
     
     with self.__lock:
         # don't allow the user to start the record process twice
         if self.rtpdump.isalive():
             msg = "rtpdump process was already running"
             raise ProcessAlreadyRunningError(msg)
         
         # name of the file we're dumping to
         dump_file = os.path.join(self.dump_dir,
                         util.generate_file_name(self.video_basename))
         
         # start the process
         self.rtpdump.start(dump_file, self.dump_address, self.dump_port)
         
         if not util.block_until(self.rtpdump.isalive, self.max_block_time):
             msg = "rtpdump process failed to start within allotted time"
             raise ProcessOperationTimeoutError(msg)
         
         # set state variables to correspond to new file if process started
         self._commit_time = None
         self._start_time = util.get_time()
         self._dump_file = dump_file
示例#2
0
    def testGenerateFileNameBase(self):
        """
        Tests proper file name generations
        """

        name = "this_is_a_test"
        file_name = util.generate_file_name(name)
        assert file_name.count(name) > 0
示例#3
0
    def testGenerateFileNameExt(self):
        """
        Tests use of the extension variable
        """

        name = "this_is_a_test"
        ext = "tst"
        file_name = util.generate_file_name(name, ext)
        assert file_name.endswith("." + ext)
示例#4
0
def get_problem_discussion(category_id):
    url = "https://discuss.leetcode.com/api/category/%s" % category_id
    res = requests.get(url)
    return ((generate_file_name(item['title']), item['slug'])
            for item in json.loads(res.content)['topics']
            if not item['deleted'])