mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-05-03 21:56:46 +00:00
[Bugfix] 修复打印中文报错异常
This commit is contained in:
parent
6586bef84c
commit
a755882100
apps
run_server.py@ -21,6 +21,7 @@ from django.shortcuts import get_object_or_404
|
||||
from django.db.models import Q
|
||||
|
||||
from common.mixins import IDInFilterMixin
|
||||
from common.utils import get_logger
|
||||
from .hands import IsSuperUser, IsValidUser, IsSuperUserOrAppUser, \
|
||||
get_user_granted_assets
|
||||
from .models import AssetGroup, Asset, Cluster, SystemUser, AdminUser
|
||||
@ -30,6 +31,9 @@ from .tasks import update_asset_hardware_info_manual, test_admin_user_connectabi
|
||||
test_system_user_connectability_manual
|
||||
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
|
||||
class AssetViewSet(IDInFilterMixin, BulkModelViewSet):
|
||||
"""
|
||||
API endpoint that allows Asset to be viewed or edited.
|
||||
@ -178,10 +182,6 @@ class SystemUserViewSet(BulkModelViewSet):
|
||||
serializer_class = serializers.SystemUserSerializer
|
||||
permission_classes = (IsSuperUserOrAppUser,)
|
||||
|
||||
def update(self, request, *args, **kwargs):
|
||||
print(request.data)
|
||||
return super().update(request, *args, **kwargs)
|
||||
|
||||
|
||||
class AssetListUpdateApi(IDInFilterMixin, ListBulkCreateUpdateDestroyAPIView):
|
||||
"""
|
||||
@ -223,6 +223,7 @@ class AssetRefreshHardwareApi(generics.RetrieveAPIView):
|
||||
asset_id = kwargs.get('pk')
|
||||
asset = get_object_or_404(Asset, pk=asset_id)
|
||||
summary = update_asset_hardware_info_manual(asset)[1]
|
||||
logger.debug("Refresh summary: {}".format(summary))
|
||||
if summary.get('dark'):
|
||||
return Response(summary['dark'].values(), status=501)
|
||||
else:
|
||||
|
@ -28,7 +28,6 @@ class AdHocResultCallback(CallbackModule):
|
||||
host = res._host.get_name()
|
||||
task_name = res.task_name
|
||||
task_result = res._result
|
||||
print(task_result)
|
||||
|
||||
if self.results_raw[t].get(host):
|
||||
self.results_raw[t][host][task_name] = task_result
|
||||
|
@ -32,7 +32,6 @@ class BaseHost(Host):
|
||||
}
|
||||
"""
|
||||
self.host_data = host_data
|
||||
print(host_data)
|
||||
hostname = host_data.get('hostname') or host_data.get('ip')
|
||||
port = host_data.get('port') or 22
|
||||
super().__init__(hostname, port)
|
||||
@ -62,7 +61,6 @@ class BaseHost(Host):
|
||||
self.set_variable("ansible_become_pass", become.get('pass', ''))
|
||||
else:
|
||||
self.set_variable("ansible_become", False)
|
||||
print(self.get_vars())
|
||||
|
||||
def __set_extra_variables(self):
|
||||
for k, v in self.host_data.get('vars', {}).items():
|
||||
|
@ -317,7 +317,10 @@ class AdHocRunHistory(models.Model):
|
||||
|
||||
@property
|
||||
def result(self):
|
||||
return json.loads(self._result)
|
||||
if self._result:
|
||||
return json.loads(self._result)
|
||||
else:
|
||||
return {}
|
||||
|
||||
@result.setter
|
||||
def result(self, item):
|
||||
@ -325,7 +328,10 @@ class AdHocRunHistory(models.Model):
|
||||
|
||||
@property
|
||||
def summary(self):
|
||||
return json.loads(self._summary)
|
||||
if self._summary:
|
||||
return json.loads(self._summary)
|
||||
else:
|
||||
return {"ok": {}, "dark": {}}
|
||||
|
||||
@summary.setter
|
||||
def summary(self, item):
|
||||
|
@ -38,7 +38,6 @@ class TaskListView(DatetimeSearchMixin, ListView):
|
||||
return self.queryset
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
print(self.date_from)
|
||||
context = {
|
||||
'app': 'Ops',
|
||||
'action': _('Task list'),
|
||||
|
@ -94,7 +94,6 @@ class AssetPermissionRemoveAssetApi(RetrieveUpdateAPIView):
|
||||
perm = self.get_object()
|
||||
serializer = self.serializer_class(data=request.data)
|
||||
if serializer.is_valid():
|
||||
print(serializer.data)
|
||||
assets = serializer.validated_data.get('assets')
|
||||
if assets:
|
||||
perm.assets.remove(*tuple(assets))
|
||||
|
@ -100,7 +100,6 @@ class UserGroupGrantedAssetView(AdminUserRequiredMixin, DetailView):
|
||||
context_object_name = 'user_group'
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
print(kwargs.get('pk'))
|
||||
self.object = self.get_object(queryset=self.model.objects.all())
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
|
@ -7,6 +7,7 @@ import time
|
||||
import argparse
|
||||
import sys
|
||||
import signal
|
||||
import io
|
||||
|
||||
from apps import __version__
|
||||
|
||||
@ -26,6 +27,7 @@ WORKERS = 4
|
||||
|
||||
EXIT_EVENT = threading.Event()
|
||||
processes = {}
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
||||
|
||||
try:
|
||||
os.makedirs(os.path.join(BASE_DIR, "data", "static"))
|
||||
@ -70,7 +72,8 @@ def start_celery():
|
||||
os.environ.setdefault('PYTHONOPTIMIZE', '1')
|
||||
|
||||
cmd = """
|
||||
export C_FORCE_ROOT=1;celery -A common worker -l {}
|
||||
export C_FORCE_ROOT=1;
|
||||
celery -A common worker -l {}
|
||||
""".format(LOG_LEVEL.lower())
|
||||
|
||||
p = subprocess.Popen(cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr)
|
||||
@ -133,6 +136,9 @@ def stop_service():
|
||||
print("Stop service {}".format(name))
|
||||
proc.terminate()
|
||||
|
||||
if os.path.exists("/tmp/beat.pid"):
|
||||
os.unlink('/tmp/beat.pid')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Jumpserver start tools")
|
||||
|
Loading…
Reference in New Issue
Block a user