# Create console handler and set level to ERROR.
ch = logging.StreamHandler()
-ch.setLevel(logging.DEBUG)
+ch.setLevel(logging.ERROR)
# Create formatter.
formatter = logging.Formatter('%(filename)s:%(lineno)s - %(levelname)s: %(message)s')
for entry in listing:
# If directory name is a number (id) add it to the list.
if os.path.isdir(os.path.join(path, entry)):
- logger.debug("folder entry: %s" %(entry))
if pattern.match(entry):
dir_list.append(int(entry))
super(TreeTextFileAccess, self).__init__(path)
def add_swarm(self, swarm):
- f = open(os.path.join(self.base_path, "swarm.conf"))
- pass
+ """
+ Create a subfolder with an unique id. Add 1 to the last numeric
+ subfolder id. In case none exists, use 1 as id.
+ """
+ id = find_last_numeric_subfolder(self.base_path)
+ if id == None:
+ id = 1
+ else:
+ id = id+1
+
+ swarm_path = os.path.join(self.base_path, str(id))
+ os.mkdir(swarm_path)
+
+ swarm_config = os.path.join(swarm_path, "swarm.conf")
+ f = open(swarm_config, 'w')
+ f.write("""id = %s
+ self.torrent_filename = %s
+ self.data_size = %s
+ self.description = %s
+ """ %(id, swarm.torrent_filename, swarm.data_size, swarm.description))
+ f.close()
def add_client_session(self, session):
pass