<commit_before>from wlanlj.nodes.models import Node
from wlanlj.generator.models import IfaceTemplate
from wlanlj.generator.types import IfaceType
from wlanlj.account.models import UserAccount
from django.conf import settings

if settings.ENABLE_IMAGE_GENERATOR:
  from beanstalk import serverconn
  from beanstalk import job

def queue_generator_job(node, email_user, config_only = False):
  """
  Queues a generator job via the beanstalk daemon.
  """
  assert(isinstance(node, Node))
  
  if not settings.ENABLE_IMAGE_GENERATOR:
    return

  # Open up a connection with beanstalkd
  queue = serverconn.ServerConn("127.0.0.1", 11300)
  queue.use("generator")

  # Prepare job metadata from profile information
  subnets = []
  for subnet in node.subnet_set.filter(allocated = True):
    # Resolve actual interface name
    try:
      iface = IfaceTemplate.objects.get(template = node.profile.template, type = subnet.gen_iface_type)
    except IfaceTemplate.DoesNotExist:
      continue

    subnets.append({
      'network'     : subnet.subnet,
      'cidr'        : subnet.cidr,
      'iface'       : iface.ifname,
      'dhcp'        : subnet.gen_dhcp
    })
  
  # Generate VPN password if needed
  profile = UserAccount.for_user(node.owner)

  data = {
    'uuid'            : node.uuid,
    'ip'              : node.ip,
    'hostname'        : node.name,
    'vpn_username'    : node.owner.username,
    'vpn_password'    : profile.vpn_password,
    'vpn_mac'         : node.vpn_mac_conf,
    'project'         : node.project.name,
    'ssid'            : node.project.ssid,
    'channel'         : node.profile.channel,
    'rx_ant'          : node.profile.antenna,
    'tx_ant'          : node.profile.antenna,
    'root_pass'       : node.profile.root_pass,<commit_msg>Properly order subnets (WiFi subnet first).<commit_after>from wlanlj.nodes.models import Node
from wlanlj.generator.models import IfaceTemplate
from wlanlj.generator.types import IfaceType
from wlanlj.account.models import UserAccount
from django.conf import settings

if settings.ENABLE_IMAGE_GENERATOR:
  from beanstalk import serverconn
  from beanstalk import job

def queue_generator_job(node, email_user, config_only = False):
  """
  Queues a generator job via the beanstalk daemon.
  """
  assert(isinstance(node, Node))
  
  if not settings.ENABLE_IMAGE_GENERATOR:
    return

  # Open up a connection with beanstalkd
  queue = serverconn.ServerConn("127.0.0.1", 11300)
  queue.use("generator")

  # Prepare job metadata from profile information
  subnets = []
  for subnet in node.subnet_set.filter(allocated = True).order_by('-gen_iface_type'):
    # Resolve actual interface name
    try:
      iface = IfaceTemplate.objects.get(template = node.profile.template, type = subnet.gen_iface_type)
    except IfaceTemplate.DoesNotExist:
      continue

    subnets.append({
      'network'     : subnet.subnet,
      'cidr'        : subnet.cidr,
      'iface'       : iface.ifname,
      'dhcp'        : subnet.gen_dhcp
    })
  
  # Generate VPN password if needed
  profile = UserAccount.for_user(node.owner)

  data = {
    'uuid'            : node.uuid,
    'ip'              : node.ip,
    'hostname'        : node.name,
    'vpn_username'    : node.owner.username,
    'vpn_password'    : profile.vpn_password,
    'vpn_mac'         : node.vpn_mac_conf,
    'project'         : node.project.name,
    'ssid'            : node.project.ssid,
    'channel'         : node.profile.channel,
    'rx_ant'          : node.profile.antenna,
    'tx_ant'          : node.profile.antenna,
    'root_pass'       : node.profile.root_pass,
{'fraction_non_alphanumeric': 0.09867330016583747, 'fraction_numerical': 0.006080707573244887, 'mean_word_length': 2.7270854788877448, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4025539', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1163, 'n_words': 254}