Skip to content

Commit

Permalink
遵循pep8规范
Browse files Browse the repository at this point in the history
  • Loading branch information
lijie3721 committed Jun 23, 2017
1 parent 6a751f9 commit 3828a2e
Show file tree
Hide file tree
Showing 27 changed files with 1,507 additions and 877 deletions.
1 change: 0 additions & 1 deletion .idea/MadKing.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

447 changes: 447 additions & 0 deletions .idea/dbnavigator.xml

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

671 changes: 306 additions & 365 deletions .idea/workspace.xml

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions MadKingClient/core/HouseStark.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,22 @@ def parse_argv(self):
self.help_msg()
def help_msg(self):
msg = '''
collect_data
collect_data 收集硬件信息
run_forever
get_asset_id
report_asset
report_asset 收集硬件信息并汇报
'''
print(msg)

def collect_data(self):
"""收集硬件信息"""
obj = info_collection.InfoCollection()
asset_data = obj.collect()
#print asset_data

def run_forever(self):
pass

def __attach_token(self,url_str):
'''generate md5 by token_id and username,and attach it on the url request'''
user = settings.Params['auth']['user']
Expand Down Expand Up @@ -82,7 +85,7 @@ def __submit_data(self,action_type,data,method):
res_data = urllib2.urlopen(req,timeout=settings.Params['request_timeout'])
callback = res_data.read()
callback = json.loads(callback)
print "\033[31;1m[%s]:[%s]\033[0m response:\n%s" %(method,url,callback)
print("\033[31;1m[%s]:[%s]\033[0m response:\n%s" %(method,url,callback))
return callback
except Exception as e:
sys.exit("\033[31;1m%s\033[0m"%e)
Expand Down Expand Up @@ -136,7 +139,7 @@ def report_asset(self):
self.log_record(response)

def log_record(self,log,action_type=None):
f = file(settings.Params["log_file"],"ab")
f = open(settings.Params["log_file"],"ab")
if log is str:
pass
if type(log) is dict:
Expand Down
4 changes: 2 additions & 2 deletions MadKingClient/core/info_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ class InfoCollection(object):
def __init__(self):
pass


def get_platform(self):

os_platform = platform.system()

return os_platform


def collect(self):
os_platform = self.get_platform()
try:
Expand All @@ -26,6 +24,7 @@ def collect(self):
return formatted_data
except AttributeError as e:
sys.exit("Error:MadKing doens't support os [%s]! " % os_platform)

def Linux(self):
sys_info = plugin_api.LinuxSysInfo()

Expand All @@ -38,6 +37,7 @@ def Windows(self):
#f.write(json.dumps(sys_info))
#f.close()
return sys_info

def build_report_data(self,data):

#add token info in here before send
Expand Down
Binary file modified assets/__pycache__/admin.cpython-35.pyc
Binary file not shown.
Binary file modified assets/__pycache__/core.cpython-35.pyc
Binary file not shown.
Binary file modified assets/__pycache__/models.cpython-35.pyc
Binary file not shown.
Binary file modified assets/__pycache__/tables.cpython-35.pyc
Binary file not shown.
Binary file modified assets/__pycache__/urls.cpython-35.pyc
Binary file not shown.
Binary file modified assets/__pycache__/views.cpython-35.pyc
Binary file not shown.
18 changes: 16 additions & 2 deletions assets/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@

from django.contrib.auth import forms as auth_form


class BaseAdmin(object):
"""自定义admin类"""


choice_fields = []
fk_fields = []
dynamic_fk = None
dynamic_list_display = []
dynamic_choice_fields = []
m2m_fields = []

class UserCreationForm(forms.ModelForm):
"""A form for creating new users. Includes all the required
fields, plus a repeated password."""
Expand Down Expand Up @@ -98,14 +110,17 @@ class CPUInline(admin.TabularInline):
model = models.CPU
exclude = ('memo',)
readonly_fields = ['create_date']

class NICInline(admin.TabularInline):
model = models.NIC
exclude = ('memo',)
readonly_fields = ['create_date']

class RAMInline(admin.TabularInline):
model = models.RAM
exclude = ('memo',)
readonly_fields = ['create_date']

class DiskInline(admin.TabularInline):
model = models.Disk
exclude = ('memo',)
Expand All @@ -130,13 +145,12 @@ class NicAdmin(admin.ModelAdmin):
search_fields = ('macaddress','ipaddress')


class EventLogAdmin(admin.ModelAdmin):
class EventLogAdmin(admin.ModelAdmin,BaseAdmin):
list_display = ('name','colored_event_type','asset','component','detail','date','user')
search_fields = ('asset',)
list_filter = ('event_type','component','date','user')



from django.contrib.contenttypes.models import ContentType
from django.http import HttpResponseRedirect

Expand Down
Loading

0 comments on commit 3828a2e

Please sign in to comment.