def mktorrent(self):
     print 'Creating torrent file...'
     torrent_temp_filename = 'temp.torrent'
     try:
         os.remove(torrent_temp_filename)
     except OSError:
         pass
     call_mktorrent(self.torrent_dir_path, torrent_temp_filename,
                    settings.WHAT_ANNOUNCE, self.torrent_new_name)
     with open(torrent_temp_filename, 'rb') as torrent_file:
         self.torrent_file_new_data = pthify_torrent(torrent_file.read())
         self.torrent_new_infohash = get_info_hash_from_data(
             self.torrent_file_new_data)
         print 'New info hash is: ', self.torrent_new_infohash
     print 'Torrent file created'
예제 #2
0
 def create_torrent(self):
     print 'Creating .torrent file...'
     args = [
         '-a', WHAT_ANNOUNCE,
         '-p',
         '-o', self.torrent_file_path,
         self.torrent_temp_dir,
     ]
     if call(['mktorrent'] + args) != 0:
         raise Exception('mktorrent returned non-zero')
     with open(self.torrent_file_path, 'rb') as f:
         torrent_data = f.read()
     torrent_data = pthify_torrent(torrent_data)
     with open(self.torrent_file_path, 'wb') as f:
         f.write(torrent_data)
     self.new_torrent_info_hash = get_info_hash(self.torrent_file_path)
 def mktorrent(self):
     print 'Creating torrent file...'
     torrent_temp_filename = 'temp.torrent'
     try:
         os.remove(torrent_temp_filename)
     except OSError:
         pass
     call_mktorrent(self.torrent_dir_path,
                    torrent_temp_filename,
                    settings.WHAT_ANNOUNCE,
                    self.torrent_new_name)
     with open(torrent_temp_filename, 'rb') as torrent_file:
         self.torrent_file_new_data = pthify_torrent(torrent_file.read())
         self.torrent_new_infohash = get_info_hash_from_data(self.torrent_file_new_data)
         print 'New info hash is: ', self.torrent_new_infohash
     print 'Torrent file created'
예제 #4
0
 def create_torrent(self):
     print 'Creating .torrent file...'
     args = [
         '-a',
         WHAT_ANNOUNCE,
         '-p',
         '-o',
         self.torrent_file_path,
         self.torrent_temp_dir,
     ]
     if call(['mktorrent'] + args) != 0:
         raise Exception('mktorrent returned non-zero')
     with open(self.torrent_file_path, 'rb') as f:
         torrent_data = f.read()
     torrent_data = pthify_torrent(torrent_data)
     with open(self.torrent_file_path, 'wb') as f:
         f.write(torrent_data)
     self.new_torrent_info_hash = get_info_hash(self.torrent_file_path)
예제 #5
0
 def make_torrent(self, metadata):
     try:
         self.stash_func()
         remove_bad_files(self.temp_dir)
         torrent_path = os.path.join(self.temp_dir,
                                     metadata.torrent_name + '.torrent')
         args = [
             'mktorrent', '-a', self.announce, '-p', '-n',
             metadata.torrent_name, '-o', torrent_path, self.temp_dir
         ]
         logger.debug('Executing mktorrent: {0}'.format(args))
         if call([q_enc(a) for a in args]) != 0:
             raise Exception('mktorrent returned non-zero')
         with open(q_enc(torrent_path), 'rb') as f:
             torrent_data = f.read()
         torrent_data = pthify_torrent(torrent_data)
         with open(q_enc(torrent_path), 'wb') as f:
             f.write(torrent_data)
     finally:
         self.unstash_func()