Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add uppercase shortcut for navigation #215

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions osc_tui/createImage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from time import sleep
import oscscreen
from osc_tui import createImage
from osc_tui import main

# All images combo box.
Expand Down
6 changes: 2 additions & 4 deletions osc_tui/createKeyPair.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import oscscreen
from osc_tui import main
from osc_tui import popup
import os

from os.path import expanduser
Expand Down Expand Up @@ -35,9 +34,8 @@ def back():
self.inspector = None

def write_key(path, private_key):
key_file = open(os.path.expanduser(path), 'w')
key_file.write(private_key)
key_file.close()
with open(os.path.expanduser(path), 'w') as key_file :
key_file.write(private_key)

def create():
if(NAME.get_value()):
Expand Down
2 changes: 0 additions & 2 deletions osc_tui/createLoadbalancer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import oscscreen
from osc_tui import main
from osc_tui import popup
import os
from osc_tui import preloader

# NAME input.
Expand Down
3 changes: 0 additions & 3 deletions osc_tui/createSnapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ def create():
return
else:
id = ID_LIST[VOLUME_COMBO.get_value()]
volume = VOLUME_COMBO.get_values()[
VOLUME_COMBO.get_value()
]
res = main.GATEWAY.CreateSnapshot(
form=self,
VolumeId=id,
Expand Down
40 changes: 21 additions & 19 deletions osc_tui/createVpcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
# List of all Subregions
SUBREGION = None


class createVpcs(oscscreen.FormBaseNew):
class CreateVpcs(oscscreen.FormBaseNew):
def __init__(self, *args, **keywords):
super().__init__(*args, **keywords)

Expand All @@ -30,14 +29,15 @@ def back():
main.kill_threads()
self.parentApp.switchForm("Cockpit")

self.inspector = None

def create():
cidr = CIDR.get_value()
res = main.GATEWAY.CreateNet(
form=self,
IpRange=cidr,
)
cidr_value = CIDR.get_value()
if cidr_value:
main.GATEWAY.CreateNet(
form=self,
IpRange=cidr_value,
)
else:
popup.errorPopup("CIDR is missing.")
back()

global CIDR
Expand All @@ -52,7 +52,7 @@ def create():
self.add_widget(oscscreen.ButtonPress, name="EXIT").whenPressed = back


class createSubnet(oscscreen.FormBaseNew):
class CreateSubnet(oscscreen.FormBaseNew):
def __init__(self, *args, **keywords):
super().__init__(*args, **keywords)

Expand All @@ -70,16 +70,18 @@ def back():
main.kill_threads()
self.parentApp.switchForm("Cockpit")

self.inspector = None

def create():
cidr = CIDRSUBNET.get_value()
res = main.GATEWAY.CreateSubnet(
form=self,
IpRange=cidr,
NetId=popup.SUBNETID,
SubregionName=SUBREGION.get_values()[SUBREGION.get_value()],
)
cidr_value = CIDRSUBNET.get_value()
subregion_value = SUBREGION.get_values()[SUBREGION.get_value()]
if cidr_value and subregion_value:
main.GATEWAY.CreateSubnet(
form=self,
IpRange=cidr_value,
NetId=popup.SUBNETID,
SubregionName=subregion_value,
)
else:
popup.errorPopup("CIDR is missing.")
back()

global CIDR
Expand Down
6 changes: 0 additions & 6 deletions osc_tui/flexibleGPU.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import oscscreen
import pyperclip

from osc_tui import createVm
from osc_tui import main
from osc_tui import popup
from osc_tui import selectableGrid
from osc_tui import virtualMachine

class Grid(selectableGrid.SelectableGrid):
def __init__(self, screen, *args, **keywords):
Expand Down
30 changes: 15 additions & 15 deletions osc_tui/guiRules.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ def objectify():
ret = None
if os.path.isfile(PATH):
ret = {}
configFile = open(PATH)
j = json.loads(configFile.read())
for rule_name in j:
rule=j[rule_name]
if "mode" not in rule:
print('"mode" is a requirre argument of costum rule',
file=sys.stderr)
if rule["mode"] not in ret:
ret[rule["mode"]] = {}
ret[rule["mode"]][rule_name] = {
"ports": rule["ports"],
"protocols": rule["protocols"]
}
if "ips" in rule:
ret[rule["mode"]][rule_name]["ips"] = rule["ips"]
with open(PATH) as configFile :
j = json.loads(configFile.read())
for rule_name in j:
rule=j[rule_name]
if "mode" not in rule:
print('"mode" is a requirre argument of costum rule',
file=sys.stderr)
if rule["mode"] not in ret:
ret[rule["mode"]] = {}
ret[rule["mode"]][rule_name] = {
"ports": rule["ports"],
"protocols": rule["protocols"]
}
if "ips" in rule:
ret[rule["mode"]][rule_name]["ips"] = rule["ips"]
return ret

def parse():
Expand Down
6 changes: 0 additions & 6 deletions osc_tui/imageGrid.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import oscscreen
import pyperclip
import time

from osc_tui import createVm
from osc_tui import main
from osc_tui import popup
from osc_tui import selectableGrid
from osc_tui import virtualMachine


class ImageGrid(selectableGrid.SelectableGrid):
Expand Down
6 changes: 0 additions & 6 deletions osc_tui/instancesGrid.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import time

import oscscreen
import pyperclip

from osc_tui import createVm
from osc_tui import main
from osc_tui import popup
from osc_tui import selectableGrid
Expand Down
5 changes: 0 additions & 5 deletions osc_tui/keyPairsGrid.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import oscscreen
import pyperclip

from osc_tui import createVm
from osc_tui import main
from osc_tui import popup
from osc_tui import selectableGrid
from osc_tui import virtualMachine


class KeyPairsGrid(selectableGrid.SelectableGrid):
Expand Down
5 changes: 0 additions & 5 deletions osc_tui/loadbalancerGrid.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import oscscreen
import pyperclip

from osc_tui import createVm
from osc_tui import main
from osc_tui import popup
from osc_tui import selectableGrid
from osc_tui import virtualMachine


class loadbalancerGrid(selectableGrid.SelectableGrid):
Expand Down
2 changes: 0 additions & 2 deletions osc_tui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from osc_tui import profileSelector
from osc_tui import guiRules

import time

# GLOBALS ATTRIBUTES
APP = None
GATEWAY = None
Expand Down
25 changes: 11 additions & 14 deletions osc_tui/mainForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import ipaddress

import oscscreen
import pyperclip

import graphviz

Expand All @@ -27,10 +26,8 @@
from osc_tui import popup
from osc_tui import securityGroupsGrid
from osc_tui import securityRulesGrid
from osc_tui import selectableGrid
from osc_tui import snapshotGrid
from osc_tui import loadbalancerGrid
from osc_tui import virtualMachine
from osc_tui import volumesGrid
from osc_tui import guiRules

Expand All @@ -44,19 +41,19 @@
LINE_SEPARATOR_COL = MENU_WIDTH + 1
GRID_START_COL = MENU_WIDTH +3

def swicthToVolumeEdit(form, id, volume):
form.parentApp.addForm("Volume-Edit",
def swicthToVolumeEdit(self, id, volume):
self.parentApp.addForm("Volume-Edit",
volumesGrid.VolumeEdit,
volume=volume,
name="osc-tui Volume-Edit {}".format(id))
form.parentApp.switchForm("Volume-Edit")
self.parentApp.switchForm("Volume-Edit")

def swicthToVolumeLink(form, id, volume):
form.parentApp.addForm("Volume-Link",
def swicthToVolumeLink(self, id, volume):
self.parentApp.addForm("Volume-Link",
volumesGrid.VolumeLink,
volume=volume,
name="osc-tui Volume-Link {}".format(id))
form.parentApp.switchForm("Volume-Link")
self.parentApp.switchForm("Volume-Link")


class mainMenu(oscscreen.MultiLineAction):
Expand Down Expand Up @@ -199,7 +196,7 @@ def actionHighlighted(self, act_on_this, key_press):
if act_on_this == 'Create new':
self.form.parentApp.addForm(
"CREATE_SUBNET",
createVpcs.createSubnet,
createVpcs.CreateSubnet,
name="osc-tui")
self.form.parentApp.switchForm("CREATE_SUBNET")
return
Expand Down Expand Up @@ -348,12 +345,12 @@ def reload(self):
self.parentApp.addForm("Cockpit", MainForm, name="osc-tui")
self.parentApp.switchForm("Cockpit")

def quit_key(form, key_val):
def quit_key(self, key_val):
main.kill_threads()
form.parentApp.switchForm("MAIN")
self.parentApp.switchForm("MAIN")

def key_reload(form, _):
form.reload()
def key_reload(self, _):
self.reload()

def set_up_handlers(self):
super().set_up_handlers()
Expand Down
3 changes: 0 additions & 3 deletions osc_tui/netAccesssPoint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import oscscreen
import pyperclip

from osc_tui import main
from osc_tui import popup
from osc_tui import selectableGrid
Expand Down
6 changes: 0 additions & 6 deletions osc_tui/netPeering.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import oscscreen
import pyperclip

from osc_tui import createVm
from osc_tui import main
from osc_tui import popup
from osc_tui import selectableGrid
from osc_tui import virtualMachine

class Grid(selectableGrid.SelectableGrid):
def __init__(self, screen, *args, **keywords):
Expand Down
3 changes: 0 additions & 3 deletions osc_tui/popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ def remove_cb():


def addSecurityGroupToVm(form, form_color='STANDOUT'):
main.SECURITY_GROUP
F = ConfirmCancelPopup(name='Add New Security Group', color=form_color)
F.preserve_selected_widget = True
groups = main.VM["SecurityGroups"]
Expand Down Expand Up @@ -674,7 +673,6 @@ def instances_registered():
)

def delete_cb():
val = main.GATEWAY.DeleteLoadBalancer(LoadBalancerName=name)
form.current_grid.h_refresh(None)
exit()

Expand Down Expand Up @@ -778,7 +776,6 @@ def associateRoutetable():
exit()

def delete_cb():
val = main.GATEWAY.DeleteSubnet(SubnetId=name)
form.current_grid.h_refresh(None)
exit()
delete.whenPressed = delete_cb
Expand Down
1 change: 0 additions & 1 deletion osc_tui/profileSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
import os
from pathlib import Path
import threading
from osc_tui import preloader

import oscscreen
Expand Down
3 changes: 0 additions & 3 deletions osc_tui/securityGroupsGrid.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@

import oscscreen
import pyperclip

from osc_tui import createVm
from osc_tui import main
from osc_tui import popup
from osc_tui import selectableGrid
from osc_tui import virtualMachine


class SecurityGroupsGrid(selectableGrid.SelectableGrid):
Expand Down
5 changes: 0 additions & 5 deletions osc_tui/securityRulesGrid.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

from osc_tui import createVm
from osc_tui import main
import oscscreen
from osc_tui import popup
import pyperclip
from osc_tui import selectableGrid
from osc_tui import virtualMachine


class SecurityRulesGrid(selectableGrid.SelectableGrid):
Expand Down
2 changes: 0 additions & 2 deletions osc_tui/selectableGrid.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import curses
import threading
import time

import oscscreen

from osc_tui import main
from osc_tui import popup
from osc_tui import mainForm

# Initially it was designed to have a thread that auto refresh... However, even if it worked fine, if too many people does it, it looks like a DDOS attack.
Expand Down
5 changes: 0 additions & 5 deletions osc_tui/snapshotGrid.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import oscscreen
import pyperclip

from osc_tui import createVm
from osc_tui import main
from osc_tui import popup
from osc_tui import selectableGrid
from osc_tui import virtualMachine


class SnapshotGrid(selectableGrid.SelectableGrid):
Expand Down
Loading