Beispiel #1
0
 def copy_file_from_remote(remote_file_location, local_target):
     try:
         System.run_command('gcloud compute scp {}:~/{} {}'.format(
             INSTANCE_NAME, remote_file_location, local_target))
         return True
     except:
         return False
Beispiel #2
0
 def file_exists_on_remote(remote_file_location):
     file_copied = GCloud.copy_file_from_remote(remote_file_location,
                                                './temp.txt')
     if file_copied:
         System.run_command('rm ./temp.txt')
         return True
     return False
    def appendSystem(self,
                     analyst: Analyst,
                     name: str = "",
                     description: str = "",
                     location: list = [],
                     router: list = [],
                     switch: list = [],
                     room: list = [],
                     testPlan: str = "",
                     archiveStatus: bool = False,
                     confidentiality: Confidentiality = Confidentiality.INFO,
                     integrity: Integrity = Integrity.INFO,
                     availability: Availability = Availability.INFO,
                     id=-1):

        new_system = System(name=name,
                            description=description,
                            location=location,
                            router=router,
                            switch=switch,
                            room=room,
                            testPlan=testPlan,
                            archiveStatus=archiveStatus,
                            confidentiality=confidentiality,
                            integrity=integrity,
                            availability=availability,
                            id=id)

        new_system.setId(
            self.__updateDatabase(analyst=analyst, system=new_system))
        self.__system.append(new_system)
        return
Beispiel #4
0
 def prompt_for_billing_id(project_id):
     os.system('gcloud alpha billing accounts list')
     billing_account_id = input(
         "Enter billing Account ID from above (if none exist create one here https://cloud.google.com/billing/docs/how-to/manage-billing-account): "
     )
     System.run_command(
         'gcloud beta billing projects link {} --billing-account={}'.format(
             project_id, billing_account_id))
Beispiel #5
0
 def __init__(self, controller, color_street):
     self._stop_car = False
     self._controller = controller
     self._color_street = color_street
     self._video_processed = None
     self._video_original = None
     self._robot = Robot()
     # self._image_to_show = STREET_ORIGINAL_IMAGE
     self._image_to_show = STREET_LINES_DRAWN
     self._send_commands_robot = True
     self._camera = Camera(source=VIDEO_CAPTURE)
     self._system = System(self._controller, self._color_street)
     self._camera.start()
Beispiel #6
0
def admin_media(request):
    """ Middleware for Jinja template

    Args:
        request (Django request)

    Returns:
        DICT: Variable for jinja template
    """
    try:
        cluster = Cluster.objects.get()
        node = cluster.get_current_node()
        assert node
        node_name = node.name

    except (ObjectDoesNotExist, AssertionError):
        node_name = ""

    menu = (System().menu, Service().menu, Authentication().menu,
            Portal().menu, Darwin().menu, Apps().menu, Workflows().menu)
    results = {
        'MENUS': menu,
        'VERSION': settings.VERSION,
        'CURRENT_NODE': node_name,
        'DEV_MODE': settings.DEV_MODE,
        'TITLE': get_hostname(),
        'COLLAPSE': request.session.get('collapse')
    }

    return results
Beispiel #7
0
 def is_authenticated():
     account = System.run_command(
         'gcloud config list account --format value(core.account)')
     if len(account):
         return True
     else:
         return False
    def updateSystem(self, system: System, analyst: Analyst):

        index = 0
        while index < len(self.__system):
            if self.__system[index].getId() == system.getId():
                self.__system[index] = system
                self.__updateDatabase(system=system, analyst=analyst)
                return
            index += 1
Beispiel #9
0
    def measure_accuracy(self, nregistered=40, nunregistered=40):
        s = System()
        registered = sample(list(DataLoader.get_img_data('registered')),
                            nregistered)
        unregistered = sample(list(DataLoader.get_img_data('unregistered')),
                              nunregistered)

        self._test_identification(s, registered)
        self._test_unregistered(s, unregistered)
Beispiel #10
0
def build_structure(count=100):
    #  "nid gid pid cid name path ref"
    nodes = [node(0, 0, '$', 1, 'Root', '~/', '$')]
    s = System(nodes)
    for n in Tree.grow(s.root):
        print(n)
    cutoff = 1.0
    max_depth = 10
    current_nid = 1
    current_level = 1
    current_parent = 1
    while bool(count):
        if random.random() < cutoff:
            n = node(current_nid, current_level, current_parent)

    print_inorder(l)
    print_inorder_indent_tree(l)

    return "system\structure.yaml"
Beispiel #11
0
def main(filepath):
    data = parser.load(filepath)
    nodes = parser.parse(data)
    system = System(nodes)
    for f in Tree.grow(system.root):
        print(f)
 def __getSystem(self, system):
     systemDoc = system.toDocument()
     return System.convertDocument(self.__database.findSystem(systemDoc))
 def __getAllSystems(self):
     docSystemList = self.__database.getAllSystems()
     systemList = []
     for document in docSystemList:
         systemList.append(System.convertDocument(document))
     return systemList
Beispiel #14
0
 def upload_directory_to_bucket(directory, bucket_name):
     buckets_list = System.run_command('gsutil ls')
     if bucket_name not in buckets_list:
         System.run_command('gsutil mb gs://{}/'.format(bucket_name))
     System.run_command('gsutil cp -r {} gs://{}/'.format(
         directory, bucket_name))
Beispiel #15
0
 def upload_file_to_bucket(file_location, bucket_name):
     buckets_list = System.run_command('gsutil ls')
     if bucket_name not in buckets_list:
         System.run_command('gsutil mb gs://{}/'.format(bucket_name))
     System.run_command('gsutil cp {} gs://{}/'.format(
         file_location, bucket_name))
Beispiel #16
0
 def create_project(project_id, project_name):
     System.run_command(
         'gcloud projects create {} --name="{}" --set-as-default'.format(
             project_id, project_name))
     System.run_command('gcloud config set project {}'.format(project_id))
Beispiel #17
0
 def login():
     System.run_command('gcloud auth login')
Beispiel #18
0
 def update_sdk():
     System.run_command('gcloud components update')
Beispiel #19
0
class AutonomousCar:
    def __init__(self, controller, color_street):
        self._stop_car = False
        self._controller = controller
        self._color_street = color_street
        self._video_processed = None
        self._video_original = None
        self._robot = Robot()
        # self._image_to_show = STREET_ORIGINAL_IMAGE
        self._image_to_show = STREET_LINES_DRAWN
        self._send_commands_robot = True
        self._camera = Camera(source=VIDEO_CAPTURE)
        self._system = System(self._controller, self._color_street)
        self._camera.start()

    def __start(self):
        Thread(target=self.update, args=()).start()

    def start(self):
        self._stop_car = False
        self._send_commands_robot = True
        self._camera.start()
        self.__start()

    def stop(self):
        self._stop_car = True
        self._send_commands_robot = False
        self._camera.stop()
        time.sleep(2)
        self._robot.stop_car()

    @property
    def video_original(self):
        return self._video_original

    @property
    def video_processed(self):
        return self._video_processed

    def image_to_show(self, option):
        self._image_to_show = option

    def send_commands_robot(self, command):
        self._send_commands_robot = command

    def backwheel_calib(self, action):
        self._robot.calibration_back_wheel(action)

    def frontwheel_calib(self, action):
        self._robot.calibration_front_wheel(action)

    def speed_request(self, speed):
        if speed > 0:
            self._robot.forward(speed)
        else:
            self._robot.backward(abs(speed))

    def turn_request(self, value):
        if (value > -45) and (value < 45):
            self._robot.turn(value)

    def commands_by_request(self, command):
        if command == "forward":
            self._robot.forward(40)
        elif command == "backward":
            self._robot.backward(40)
        elif command == "right":
            self._robot.turn(35)
        elif command == "left":
            self._robot.turn(-35)
        elif command == "straight":
            self._robot.turn(0)
        elif command == "stop":
            self._robot.stop_car()
        else:
            print "Command to Picar-V not found"

    def get_log_car(self):
        return self._system.get_log_system()

    def update(self):
        self._system.reset_log()
        video_output = video_writer()
        while not self._stop_car:
            # self._video_original = self.image_test()
            self._video_original = self._camera.frame
            self._video_processed, speed, angle = self._system.output(
                self._video_original, self._image_to_show)
            video_output.write(self._video_processed)
            if self._send_commands_robot:
                self._robot.forward(speed)
                self._robot.turn(angle)
            else:
                self._robot.forward(0)
                # Keep only turn command active
                self._robot.turn(angle)
                # self._robot.turn(0)
        video_output.release()