# Path: pytorque/models.py
# class PBSServer(models.Model):
#     time = models.DateTimeField(
#         default=datetime.now)#auto_now_add=True sets datetime with creating object, not with every modifying action
# 
#     name = models.CharField(max_length=100)
#     state = models.CharField(max_length=20)
#     total_jobs = models.IntegerField()
#     running_jobs = models.IntegerField()
#     queued_jobs = models.IntegerField()
#     pbs_version = models.CharField(max_length=10)
# 
# class PBSQueue(models.Model):
#     server = models.ForeignKey(PBSServer)#, blank=True, null=True, on_delete=models.SET_NULL
#     time = models.DateTimeField(default=datetime.now)
# 
#     name = models.CharField(default='', max_length=100, blank=True, null=True)
#     type = models.CharField(default='', max_length=20, blank=True, null=True)
#     total_jobs = models.IntegerField(default=0)
#     running_jobs = models.IntegerField(default=0)
#     queued_jobs = models.IntegerField(default=0)
#     resource_walltime = models.CharField(default='', max_length=20, blank=True, null=True)
#     resource_nodes = models.IntegerField(default=0)
# 
# class PBSJob(models.Model):
#     user = models.ForeignKey(User)
#     queue = models.ForeignKey(PBSQueue)
#     time = models.DateTimeField(default=datetime.now)
# 
#     jobId = models.CharField(default='', max_length=50, blank=True, null=True)
#     name = models.CharField(default='', max_length=100, blank=True, null=True)
#     owner = models.CharField(default='', max_length=100, blank=True, null=True)
#     state = models.CharField(default='', max_length=10, blank=True, null=True)
#     queue_raw = models.CharField(default='', max_length=100, blank=True, null=True)
# 
#     start_time = models.DateTimeField(default=datetime.now, blank=True, null=True)
#     resource_cput = models.CharField(default='', max_length=20, blank=True, null=True)
#     resource_mem = models.CharField(default='', max_length=20, blank=True, null=True)
#     resource_vmem = models.CharField(default='', max_length=20, blank=True, null=True)
#     resource_walltime = models.CharField(default='', max_length=20, blank=True, null=True)


from datetime import  datetime
from PBSQuery import PBSQuery, PBSError
from django.contrib.auth.models import User
from pytorque.models import PBSServer, PBSQueue, PBSJob
import time
import pbs
    name = None
    cpu_time = None
    n_p = None
    queued = None
    started = None
    running_time = None

    def __init__(self, jobId):
        self.jobId = jobId

    def setQueued(self, queuedTime):
        self.queued = time.strftime(self.__datetime_format, time.localtime(int(queuedTime)))

    def setStarted(self, startedTime):
        self.started = time.strftime(self.__datetime_format, time.localtime(int(startedTime)))


class TorqueService():
    @staticmethod
    def _listToStr(list, delimiter):
        result = ''
        if list:
            for element in list:
                result += str(element) + delimiter
            result = result[:-1]

        return result

    @staticmethod
    def _listToInt(list, default_value=0):

# Path: pytorque/models.py
# class PBSServer(models.Model):
#     time = models.DateTimeField(
#         default=datetime.now)#auto_now_add=True sets datetime with creating object, not with every modifying action
# 
#     name = models.CharField(max_length=100)
#     state = models.CharField(max_length=20)
#     total_jobs = models.IntegerField()
#     running_jobs = models.IntegerField()
#     queued_jobs = models.IntegerField()
#     pbs_version = models.CharField(max_length=10)
# 
# class PBSQueue(models.Model):
#     server = models.ForeignKey(PBSServer)#, blank=True, null=True, on_delete=models.SET_NULL
#     time = models.DateTimeField(default=datetime.now)
# 
#     name = models.CharField(default='', max_length=100, blank=True, null=True)
#     type = models.CharField(default='', max_length=20, blank=True, null=True)
#     total_jobs = models.IntegerField(default=0)
#     running_jobs = models.IntegerField(default=0)
#     queued_jobs = models.IntegerField(default=0)
#     resource_walltime = models.CharField(default='', max_length=20, blank=True, null=True)
#     resource_nodes = models.IntegerField(default=0)
# 
# class PBSJob(models.Model):
#     user = models.ForeignKey(User)
#     queue = models.ForeignKey(PBSQueue)
#     time = models.DateTimeField(default=datetime.now)
# 
#     jobId = models.CharField(default='', max_length=50, blank=True, null=True)
#     name = models.CharField(default='', max_length=100, blank=True, null=True)
#     owner = models.CharField(default='', max_length=100, blank=True, null=True)
#     state = models.CharField(default='', max_length=10, blank=True, null=True)
#     queue_raw = models.CharField(default='', max_length=100, blank=True, null=True)
# 
#     start_time = models.DateTimeField(default=datetime.now, blank=True, null=True)
#     resource_cput = models.CharField(default='', max_length=20, blank=True, null=True)
#     resource_mem = models.CharField(default='', max_length=20, blank=True, null=True)
#     resource_vmem = models.CharField(default='', max_length=20, blank=True, null=True)
#     resource_walltime = models.CharField(default='', max_length=20, blank=True, null=True)


# Path: pytorque/libs/torque_service.py
from datetime import  datetime
from PBSQuery import PBSQuery, PBSError
from django.contrib.auth.models import User
from pytorque.models import PBSServer, PBSQueue, PBSJob
import time
import pbs

    name = None
    cpu_time = None
    n_p = None
    queued = None
    started = None
    running_time = None

    def __init__(self, jobId):
        self.jobId = jobId

    def setQueued(self, queuedTime):
        self.queued = time.strftime(self.__datetime_format, time.localtime(int(queuedTime)))

    def setStarted(self, startedTime):
        self.started = time.strftime(self.__datetime_format, time.localtime(int(startedTime)))


class TorqueService():
    @staticmethod
    def _listToStr(list, delimiter):
        result = ''
        if list:
            for element in list:
                result += str(element) + delimiter
            result = result[:-1]

        return result

    @staticmethod
    def _listToInt(list, default_value=0):

        result = default_value