+ """
+ Create session subfolder in swarm subfolder and add config file.
+ TODO: Throw exception in case swarm subfolder doesn't exist.
+ """
+ swarm_path = os.path.join(self.base_path, str(session.swarm_id))
+
+ # Search first available folder in swarm_path.
+ id = find_last_numeric_subfolder(swarm_path)
+ if id == None:
+ id = 1
+ else:
+ id = id+1
+
+ # Create session subfolder.
+ session_path = os.path.join(swarm_path, str(id))
+ os.mkdir(session_path)
+
+ # Create and populate configuration file.
+ session_config = os.path.join(session_path, "client_session.conf")
+ f = open(session_config, 'w')
+ f.write("""id = %s
+ swarm_id = %s
+ btclient = %s
+ system_os = %s
+ system_os_version = %s
+ system_ram = %s
+ system_cpu = %s
+ public_ip = %s
+ public_port = %s
+ ds_limit = %s
+ us_limit = %s
+ start_time = %s
+ dht_enabled = %s
+ pxe_enabled = %s
+ streaming_enabled = %s
+ features = %s
+ description = %s
+ """ %(id, session.swarm_id, session.btclient, session.system_os,
+ session.system_os_version, session.system_ram, session.system_cpu,
+ session.public_ip, session.public_port, session.ds_limit,
+ session.us_limit, session.start_time, session.dht_enabled,
+ session.pxe_enabled, session.streaming_enabled,
+ session.features, session.description))
+ f.close()