Skip to content
Merged
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
19 changes: 12 additions & 7 deletions mig/shared/functionality/vncsession.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# --- BEGIN_HEADER ---
#
# vncsession - Start a new VNC session
# Copyright (C) 2003-2023 The MiG Project lead by Brian Vinter
# vncsession - Start a new VNC session for interactive jobs
# Copyright (C) 2003-2026 The MiG Project by the Science HPC Center at UCPH
#
# This file is part of MiG.
#
Expand All @@ -20,12 +20,12 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Check warning on line 23 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

Check warning on line 23 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# -- END_HEADER ---
#

"""Start a new vnc session"""
"""Start a new vnc session for interactive jobs"""

from __future__ import absolute_import

Expand Down Expand Up @@ -56,10 +56,10 @@
return ['html_form', defaults]


def main(client_id, user_arguments_dict):

Check failure on line 59 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'main' (60% confidence)

Check failure on line 59 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'main' (60% confidence)
"""Main function used by front end"""

(configuration, logger, output_objects, op_name) = \

Check failure on line 62 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'op_name' (60% confidence)

Check failure on line 62 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'op_name' (60% confidence)
initialize_main_variables(client_id, op_header=False)
client_dir = client_id_dir(client_id)
defaults = signature()[1]
Expand All @@ -79,6 +79,11 @@
depth = accepted['depth'][-1]
desktopname = accepted['desktopname'][-1]

if not configuration.site_enable_jobs:
output_objects.append({'object_type': 'error_text', 'text':
'''Job execution is not enabled on this system'''})

Check warning on line 84 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)

Check warning on line 84 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
return (output_objects, returnvalues.SYSTEM_ERROR)

# Please note that base_dir must end in slash to avoid access to other
# user dirs when own name is a prefix of another user name

Expand All @@ -95,10 +100,10 @@
var httpRequest = new XMLHttpRequest();
try {
httpRequest.open("POST", "vncstop.py", "");
httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

Check warning on line 103 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (90 > 80 characters)

Check warning on line 103 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (90 > 80 characters)
httpRequest.send("");
}
catch (e)

Check warning on line 106 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

trailing whitespace

Check warning on line 106 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

trailing whitespace
{
alert(e);
return e;
Expand All @@ -106,7 +111,7 @@
}
'''

# ## TODO: Include something like the following for support for interactive jobrequests!

Check warning on line 114 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (92 > 80 characters)

Check warning on line 114 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (92 > 80 characters)
# ===============================================================================
# function submitjob(request) {
# if (!window.XMLHttpRequest)
Expand All @@ -115,7 +120,7 @@
# var httpRequest = new XMLHttpRequest();
# try {
# httpRequest.open('POST', 'textarea.py', '');
# httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

Check warning on line 123 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (95 > 80 characters)

Check warning on line 123 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (95 > 80 characters)
# httpRequest.send(request);
# }
# catch (e) {
Expand All @@ -128,10 +133,10 @@
# return httpRequest.status + " " + httpRequest.statusText;
# }
# ##############################################################333
# ....FOLLOWING IS A SAMPLE TAKEN FROM: dsl.gymer.dk (thx. for sharing gymer)

Check warning on line 136 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

Check warning on line 136 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
# ....function submitkey() {
# .... var form = document.getElementById("submitkeyform");
# .... var res = submitjob("action=submitkey"+"&key="+form.key.value );

Check warning on line 139 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)

Check warning on line 139 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
# .... document.getElementById("subcontent").innerHTML = res;
# ....}
# ===============================================================================
Expand All @@ -146,8 +151,8 @@
error = ''

# Find available port/display.
# TODO: Separate port and display no... Check /tmp/.X11-lock/ for available displays

Check warning on line 154 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (88 > 80 characters)

Check warning on line 154 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (88 > 80 characters)
# ....and make bind check for available ports! Display might be in use without

Check warning on line 155 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)

Check warning on line 155 in mig/shared/functionality/vncsession.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
# ....using a port and vice-versa!

passwdfile = ''
Expand All @@ -172,15 +177,15 @@
for i in range(start_display, VNC_port_count + start_display):
free_display_found = False
try:
S = socket.socket()
S.bind(('', baseVNCport + i))
vnc_sock = socket.socket()
vnc_sock.bind((configuration.server_fqdn, baseVNCport + i))
display_number = i
vnc_port = baseVNCport + display_number
free_display_found = True
except Exception as exc:
error = exc
S.close()
S = None
vnc_sock.close()
vnc_sock = None

if free_display_found:

Expand Down
Loading