lines
sequencelengths
1
444
raw_lines
sequencelengths
1
444
label
sequencelengths
1
444
type
sequencelengths
1
444
[ "def FUNC_3(self):...\n", "if self.telnet:\n", "self.telnet.write(bytes('quit\\r', encoding='utf-8'))\n", "super().close()\n" ]
[ "def close(self):...\n", "if self.telnet:\n", "self.telnet.write(bytes('quit\\r', encoding='utf-8'))\n", "super().close()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Expr'" ]
[ "@tornado.gen.coroutine...\n", "VAR_17 = 'SELECT {} FROM districts WHERE name = %s'.format(VAR_6)\n", "VAR_18 = VAR_8,\n", "VAR_19 = yield VAR_1.execute(query=sql, VAR_18=params)\n", "return VAR_19.fetchone()\n" ]
[ "@tornado.gen.coroutine...\n", "sql = 'SELECT {} FROM districts WHERE name = %s'.format(cols)\n", "params = name,\n", "cursor = yield tx.execute(query=sql, params=params)\n", "return cursor.fetchone()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_2(VAR_8, VAR_9):...\n", "if VAR_8 == VAR_1 - 1:\n", "VAR_15 = [frozenset((VAR_9[i], VAR_9[i + 1])) for i in range(len(VAR_9) - 1)]\n", "for node in VAR_3[VAR_8]:\n", "VAR_13 = sum(VAR_4[edge] for edge in VAR_15)\n", "if node not in VAR_9:\n", "if VAR_13 < VAR_6:\n", "VAR_9.append(node)\n", "VAR_7 = set(VAR_15)\n", "if VAR_13 == VAR_6:\n", "FUNC_2(node, VAR_9)\n", "VAR_6 = VAR_13\n", "VAR_7 = VAR_7.union(VAR_15)\n", "VAR_9.pop()\n" ]
[ "def dfs_recur(current_node, path):...\n", "if current_node == num_points - 1:\n", "edges = [frozenset((path[i], path[i + 1])) for i in range(len(path) - 1)]\n", "for node in adj_lst[current_node]:\n", "length = sum(trail_len[edge] for edge in edges)\n", "if node not in path:\n", "if length < shortest_path:\n", "path.append(node)\n", "flower_path = set(edges)\n", "if length == shortest_path:\n", "dfs_recur(node, path)\n", "shortest_path = length\n", "flower_path = flower_path.union(edges)\n", "path.pop()\n" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "For", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_4(self, VAR_10, VAR_12, VAR_13):...\n", "if VAR_10.get_visibility():\n", "VAR_10.set_invisible_char('●')\n", "VAR_10.set_visibility(True)\n", "VAR_10.set_visibility(False)\n" ]
[ "def on_password_unlock_entry_secondary_clicked(self, widget, position,...\n", "if widget.get_visibility():\n", "widget.set_invisible_char('●')\n", "widget.set_visibility(True)\n", "widget.set_visibility(False)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_28(self, VAR_15):...\n", "" ]
[ "def edit(self, item):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_15(self):...\n", "for VAR_7 in default_fields:\n", "if VAR_7 not in self.__dict__:\n", "for VAR_7 in self.get_valid_columns():\n", "self.__dict__[VAR_7] = None\n", "if VAR_7 in ('idx', 'docstatus') and self.__dict__[VAR_7] is None:\n", "if VAR_7 not in self.__dict__:\n", "self.__dict__[VAR_7] = 0\n", "self.__dict__[VAR_7] = None\n" ]
[ "def init_valid_columns(self):...\n", "for key in default_fields:\n", "if key not in self.__dict__:\n", "for key in self.get_valid_columns():\n", "self.__dict__[key] = None\n", "if key in ('idx', 'docstatus') and self.__dict__[key] is None:\n", "if key not in self.__dict__:\n", "self.__dict__[key] = 0\n", "self.__dict__[key] = None\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Condition", "For", "Assign'", "Condition", "Condition", "Assign'", "Assign'" ]
[ "@FUNC_3...\n", "\"\"\"docstring\"\"\"\n", "VAR_27 = []\n", "def FUNC_15(VAR_38):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_38:\n", "return None\n", "if isinstance(VAR_38, basestring):\n", "for d in self.doc_types:\n", "if not any(d['name'] == VAR_38['name'] for d in VAR_27):\n", "if d['name'] == VAR_38:\n", "VAR_38 = VAR_38.copy()\n", "return VAR_38['name']\n", "VAR_38 = d\n", "VAR_38['example'] = json.dumps(VAR_38['example'], sort_keys=True,\n separators=(', ', ': '), indent=2)\n", "VAR_27.append(VAR_38)\n" ]
[ "@redirect_ui_on_replica...\n", "\"\"\"docstring\"\"\"\n", "doc_types = []\n", "def add_doc_type(tp):...\n", "\"\"\"docstring\"\"\"\n", "if not tp:\n", "return None\n", "if isinstance(tp, basestring):\n", "for d in self.doc_types:\n", "if not any(d['name'] == tp['name'] for d in doc_types):\n", "if d['name'] == tp:\n", "tp = tp.copy()\n", "return tp['name']\n", "tp = d\n", "tp['example'] = json.dumps(tp['example'], sort_keys=True, separators=(', ',\n ': '), indent=2)\n", "doc_types.append(tp)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "For", "For", "Condition", "Assign'", "Return'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_11(self, VAR_14):...\n", "\"\"\"docstring\"\"\"\n", "if type(VAR_14) != type(u''):\n", "VAR_14 = VAR_14.decode('utf8')\n", "VAR_14 = VAR_14[:self._mlen]\n", "VAR_26 = 'string' % {'input_phrase': VAR_14}\n", "VAR_35 = self.db.execute(VAR_26).fetchall()\n", "VAR_36 = self.hunspell_obj.suggest(VAR_14)\n", "for ele in VAR_36:\n", "VAR_35.append(tuple(ele))\n", "VAR_37 = {}\n", "VAR_21 = {}\n", "VAR_38 = {}\n", "map(lambda x: VAR_38.update([(x[3:-2], x[:])]), filter(lambda x: not x[-1],\n VAR_35))\n", "map(lambda x: VAR_37.update([(x[3:-2], x[:])]), filter(lambda x: x[-2] in [\n 0, -1] and x[-1], VAR_35))\n", "map(lambda x: VAR_21.update([(x[3:-2], x[:])]), filter(lambda x: x[-2] not in\n [0, -1] and x[-1], VAR_35))\n", "VAR_39 = VAR_21.values()\n", "map(VAR_39.append, filter(lambda x: x, map(lambda VAR_4: VAR_4 not in\n VAR_21 and VAR_37[VAR_4], VAR_37)))\n", "map(VAR_39.append, filter(lambda x: x, map(lambda VAR_4: VAR_4 not in\n VAR_21 and VAR_4 not in VAR_37 and VAR_38[VAR_4], VAR_38)))\n", "VAR_39.sort(cmp=lambda x, y: -cmp(x[-1], y[-1]) or cmp(x[1], y[1]) or -cmp(\n x[-2], y[-2]) or cmp(x[0], y[0]))\n", "return VAR_39[:]\n" ]
[ "def select_words(self, input_phrase):...\n", "\"\"\"docstring\"\"\"\n", "if type(input_phrase) != type(u''):\n", "input_phrase = input_phrase.decode('utf8')\n", "input_phrase = input_phrase[:self._mlen]\n", "sqlstr = (\n \"\"\"SELECT * FROM user_db.phrases WHERE phrase LIKE \"%(input_phrase)s%%\"\n UNION ALL\n SELECT * FROM mudb.phrases WHERE phrase LIKE \"%(input_phrase)s%%\"\n ORDER BY user_freq DESC, freq DESC, id ASC, mlen ASC\n limit 1000;\"\"\"\n % {'input_phrase': input_phrase})\n", "result = self.db.execute(sqlstr).fetchall()\n", "hunspell_list = self.hunspell_obj.suggest(input_phrase)\n", "for ele in hunspell_list:\n", "result.append(tuple(ele))\n", "usrdb = {}\n", "mudb = {}\n", "sysdb = {}\n", "map(lambda x: sysdb.update([(x[3:-2], x[:])]), filter(lambda x: not x[-1],\n result))\n", "map(lambda x: usrdb.update([(x[3:-2], x[:])]), filter(lambda x: x[-2] in [0,\n -1] and x[-1], result))\n", "map(lambda x: mudb.update([(x[3:-2], x[:])]), filter(lambda x: x[-2] not in\n [0, -1] and x[-1], result))\n", "_cand = mudb.values()\n", "map(_cand.append, filter(lambda x: x, map(lambda key: key not in mudb and\n usrdb[key], usrdb)))\n", "map(_cand.append, filter(lambda x: x, map(lambda key: key not in mudb and \n key not in usrdb and sysdb[key], sysdb)))\n", "_cand.sort(cmp=lambda x, y: -cmp(x[-1], y[-1]) or cmp(x[1], y[1]) or -cmp(x\n [-2], y[-2]) or cmp(x[0], y[0]))\n", "return _cand[:]\n" ]
[ 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_23(self, VAR_14):...\n", "" ]
[ "def is_unique(self, col_name):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return import_from_settings('LOGOUT_REDIRECT_URL', '/')\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return import_from_settings('LOGOUT_REDIRECT_URL', '/')\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def __init__(self, VAR_1, VAR_2, VAR_3, VAR_4):...\n", "\"\"\"docstring\"\"\"\n", "super(CLASS_2, self).__init__(VAR_1, VAR_2)\n", "self.hostname = VAR_3\n", "self.host_status = VAR_4\n" ]
[ "def __init__(self, pid, comp_name, hostname, host_status):...\n", "\"\"\"docstring\"\"\"\n", "super(RemoteComponentMonitoringJob, self).__init__(pid, comp_name)\n", "self.hostname = hostname\n", "self.host_status = host_status\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'" ]
[ "def FUNC_9(self, VAR_20, VAR_23):...\n", "VAR_58 = super(CLASS_2.MockHTTPProvider, self).new_connection(VAR_20, VAR_23)\n", "VAR_59 = mock.Mock()\n", "VAR_60 = VAR_58.send\n", "def FUNC_21(VAR_49, **VAR_18):...\n", "VAR_63 = mock.Mock()\n", "VAR_63.history = None\n", "VAR_63.headers = {'location': ''}\n", "VAR_63.raw._original_response = {}\n", "VAR_20.record_call(VAR_49, **kwargs)\n", "return VAR_63\n" ]
[ "def new_connection(self, cluster_api, provider):...\n", "session = super(NsxClientTestCase.MockHTTPProvider, self).new_connection(\n cluster_api, provider)\n", "mock_adapter = mock.Mock()\n", "session_send = session.send\n", "def _adapter_send(request, **kwargs):...\n", "mock_response = mock.Mock()\n", "mock_response.history = None\n", "mock_response.headers = {'location': ''}\n", "mock_response.raw._original_response = {}\n", "cluster_api.record_call(request, **kwargs)\n", "return mock_response\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_24(self):...\n", "return self.authenticated\n" ]
[ "def is_authenticated(self):...\n", "return self.authenticated\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_7(self, VAR_11):...\n", "\"\"\"docstring\"\"\"\n" ]
[ "def create_snapshot(self, snapshot):...\n", "\"\"\"docstring\"\"\"\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Docstring" ]
[ "def FUNC_40(self, VAR_35):...\n", "\"\"\"docstring\"\"\"\n", "for VAR_40, (i, j) in VAR_35:\n", "self.set_name(VAR_40, i, VAR_42=j)\n" ]
[ "def take_names(self, names):...\n", "\"\"\"docstring\"\"\"\n", "for name, (i, j) in names:\n", "self.set_name(name, i, end=j)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Expr'" ]
[ "\"\"\"Handlers for customizing oauthclient endpoints.\"\"\"\n", "import six\n", "from flask import current_app, flash, redirect, render_template, request, session, url_for\n", "from flask.ext.login import current_user\n", "from functools import partial, wraps\n", "from werkzeug.utils import import_string\n", "from invenio.base.globals import cfg\n", "from .client import oauth, signup_handlers\n", "from .errors import OAuthClientError, OAuthError, OAuthRejectedRequestError, OAuthResponseError\n", "from .forms import EmailSignUpForm\n", "from .models import RemoteAccount, RemoteToken\n", "from .utils import oauth_authenticate, oauth_get_user, oauth_register\n", "def FUNC_0(VAR_0):...\n", "\"\"\"docstring\"\"\"\n", "return '%s_%s' % (cfg['OAUTHCLIENT_SESSION_KEY_PREFIX'], VAR_0)\n" ]
[ "\"\"\"Handlers for customizing oauthclient endpoints.\"\"\"\n", "import six\n", "from flask import current_app, flash, redirect, render_template, request, session, url_for\n", "from flask.ext.login import current_user\n", "from functools import partial, wraps\n", "from werkzeug.utils import import_string\n", "from invenio.base.globals import cfg\n", "from .client import oauth, signup_handlers\n", "from .errors import OAuthClientError, OAuthError, OAuthRejectedRequestError, OAuthResponseError\n", "from .forms import EmailSignUpForm\n", "from .models import RemoteAccount, RemoteToken\n", "from .utils import oauth_authenticate, oauth_get_user, oauth_register\n", "def token_session_key(remote_app):...\n", "\"\"\"docstring\"\"\"\n", "return '%s_%s' % (cfg['OAUTHCLIENT_SESSION_KEY_PREFIX'], remote_app)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_4(self):...\n", "return dbi\n" ]
[ "def dbapiModule(self):...\n", "return dbi\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_4(self, VAR_9):...\n", "" ]
[ "def _prepare_error_msg(self, msg):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_1(VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_4(**VAR_4):...\n", "return VAR_5()\n" ]
[ "def create_on_missing(factory):...\n", "\"\"\"docstring\"\"\"\n", "def on_missing(**kwargs):...\n", "return factory()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Return'" ]
[ "@VAR_0.route('/ping')...\n", "return 'pong'\n" ]
[ "@locations.route('/ping')...\n", "return 'pong'\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_14(self, VAR_22=4567, VAR_23='127.0.0.1'):...\n", "reactor.listenTCP(VAR_22, PixelatedSite(self.resource), interface=host)\n" ]
[ "def listenTCP(self, port=4567, host='127.0.0.1'):...\n", "reactor.listenTCP(port, PixelatedSite(self.resource), interface=host)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_3():...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = environ.paths.package()\n", "VAR_12 = environ.paths.resources()\n", "VAR_13 = list(traceback.extract_tb(sys.exc_info()[-1])).copy()\n", "def FUNC_7(VAR_14: str) ->bool:...\n", "if not VAR_14 or not VAR_14.startswith(VAR_11):\n", "return False\n", "if VAR_14.startswith(VAR_12):\n", "return False\n", "return True\n" ]
[ "def get_stack_frames():...\n", "\"\"\"docstring\"\"\"\n", "cauldron_path = environ.paths.package()\n", "resources_path = environ.paths.resources()\n", "frames = list(traceback.extract_tb(sys.exc_info()[-1])).copy()\n", "def is_cauldron_code(test_filename: str) ->bool:...\n", "if not test_filename or not test_filename.startswith(cauldron_path):\n", "return False\n", "if test_filename.startswith(resources_path):\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_8(self, VAR_7, VAR_9, VAR_10=False):...\n", "if isinstance(VAR_9, list) and not VAR_10:\n", "self.__dict__[VAR_7] = []\n", "self.__dict__[VAR_7] = VAR_9\n", "self.extend(VAR_7, VAR_9)\n" ]
[ "def set(self, key, value, as_value=False):...\n", "if isinstance(value, list) and not as_value:\n", "self.__dict__[key] = []\n", "self.__dict__[key] = value\n", "self.extend(key, value)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_5(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_22 = list(filter(lambda VAR_26: not VAR_26.qualified_name.startswith(\n 'sudo'), self.bot.walk_commands()))\n", "VAR_23 = random.choice(VAR_22)\n", "return self.bot.change_presence(game=discord.Game(name=\n f'for {self.bot.command_prefix}{command.qualified_name}', type=3))\n" ]
[ "def next_activity(self):...\n", "\"\"\"docstring\"\"\"\n", "command_choice = list(filter(lambda c: not c.qualified_name.startswith(\n 'sudo'), self.bot.walk_commands()))\n", "command = random.choice(command_choice)\n", "return self.bot.change_presence(game=discord.Game(name=\n f'for {self.bot.command_prefix}{command.qualified_name}', type=3))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_4(self, VAR_5='/'):...\n", "VAR_6 = os.path.join(self.namespace, VAR_5)\n", "if VAR_6 != '/':\n", "VAR_6 = VAR_6.rstrip('/')\n", "VAR_7 = self.etcd.read(VAR_6, recursive=True)\n", "return None\n", "VAR_3 = FUNC_2()\n", "for entry in VAR_7.get_subtree():\n", "if entry.key == VAR_6:\n", "return sorted(VAR_3)\n", "VAR_8 = entry.key[len(VAR_6):]\n", "if entry.dir and not VAR_8.endswith('/'):\n", "VAR_8 += '/'\n", "VAR_3.add(VAR_8.lstrip('/'))\n" ]
[ "def list(self, keyfilter='/'):...\n", "path = os.path.join(self.namespace, keyfilter)\n", "if path != '/':\n", "path = path.rstrip('/')\n", "result = self.etcd.read(path, recursive=True)\n", "return None\n", "value = set()\n", "for entry in result.get_subtree():\n", "if entry.key == path:\n", "return sorted(value)\n", "name = entry.key[len(path):]\n", "if entry.dir and not name.endswith('/'):\n", "name += '/'\n", "value.add(name.lstrip('/'))\n" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Assign'", "For", "Condition", "Return'", "Assign'", "Condition", "AugAssign'", "Expr'" ]
[ "def FUNC_6(self):...\n", "\"\"\"docstring\"\"\"\n", "tools.connect()\n" ]
[ "def test_connect_to_database(self):...\n", "\"\"\"docstring\"\"\"\n", "tools.connect()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'" ]
[ "def FUNC_1(self, **VAR_3):...\n", "VAR_13 = super().get_context_data(**kwargs)\n", "VAR_13['is_mobile'] = FUNC_0(self.request.META['HTTP_USER_AGENT'])\n", "return VAR_13\n" ]
[ "def get_context_data(self, **kwargs):...\n", "context = super().get_context_data(**kwargs)\n", "context['is_mobile'] = is_mobile(self.request.META['HTTP_USER_AGENT'])\n", "return context\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_10(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_25 = VAR_18.pop('oidc_csrf_token')\n", "VAR_0.debug(\"Can't retrieve CSRF token, state, or code\", exc_info=True)\n", "if VAR_17 != VAR_25:\n", "VAR_19 = json.loads(request.args['state'])\n", "return self.oidc_error()\n", "VAR_0.debug('CSRF token mismatch')\n", "VAR_16 = self.flow_for_request()\n", "VAR_17 = VAR_19['csrf_token']\n", "return self.oidc_error()\n", "VAR_22 = VAR_16.step2_exchange(VAR_13, VAR_3=self.http)\n", "VAR_10 = VAR_19['destination']\n", "VAR_6 = VAR_22.id_token\n", "VAR_13 = request.args['code']\n", "if not self.is_id_token_valid(VAR_6):\n", "VAR_0.debug('Invalid ID token')\n", "self.credentials_store[VAR_6['sub']] = VAR_22\n", "if VAR_6.get('hd') != self.app.config['OIDC_GOOGLE_APPS_DOMAIN']:\n", "VAR_7 = redirect(VAR_10)\n", "return self.oidc_error('You must log in with an account from the {0} domain.'\n .format(self.app.config['OIDC_GOOGLE_APPS_DOMAIN']), self.\n WRONG_GOOGLE_APPS_DOMAIN)\n", "return self.oidc_error()\n", "self.set_cookie_id_token(VAR_6)\n", "return VAR_7\n" ]
[ "def oidc_callback(self):...\n", "\"\"\"docstring\"\"\"\n", "session_csrf_token = session.pop('oidc_csrf_token')\n", "logger.debug(\"Can't retrieve CSRF token, state, or code\", exc_info=True)\n", "if csrf_token != session_csrf_token:\n", "state = json.loads(request.args['state'])\n", "return self.oidc_error()\n", "logger.debug('CSRF token mismatch')\n", "flow = self.flow_for_request()\n", "csrf_token = state['csrf_token']\n", "return self.oidc_error()\n", "credentials = flow.step2_exchange(code, http=self.http)\n", "destination = state['destination']\n", "id_token = credentials.id_token\n", "code = request.args['code']\n", "if not self.is_id_token_valid(id_token):\n", "logger.debug('Invalid ID token')\n", "self.credentials_store[id_token['sub']] = credentials\n", "if id_token.get('hd') != self.app.config['OIDC_GOOGLE_APPS_DOMAIN']:\n", "response = redirect(destination)\n", "return self.oidc_error('You must log in with an account from the {0} domain.'\n .format(self.app.config['OIDC_GOOGLE_APPS_DOMAIN']), self.\n WRONG_GOOGLE_APPS_DOMAIN)\n", "return self.oidc_error()\n", "self.set_cookie_id_token(id_token)\n", "return response\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Condition", "Assign'", "Return'", "Expr'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Return'", "Return'", "Expr'", "Return'" ]
[ "def FUNC_45(self):...\n", "def FUNC_57():...\n", "self.cursor.execute('create table t1 (word varchar (100))')\n", "VAR_38 = set(['a'])\n", "self.cursor.execute('insert into t1 (word) VALUES (?)', [VAR_38])\n", "self.assertRaises(pyodbc.ProgrammingError, FUNC_57)\n" ]
[ "def test_sets_execute(self):...\n", "def f():...\n", "self.cursor.execute('create table t1 (word varchar (100))')\n", "words = set(['a'])\n", "self.cursor.execute('insert into t1 (word) VALUES (?)', [words])\n", "self.assertRaises(pyodbc.ProgrammingError, f)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Expr'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_7(VAR_11):...\n", "return True\n" ]
[ "def directory_filter(_path):...\n", "return True\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "import cgi\n", "import os, sys\n", "import funct\n", "import sql\n", "import ovw\n", "VAR_0 = cgi.FieldStorage()\n", "VAR_1 = VAR_0.getvalue('serv')\n", "VAR_2 = VAR_0.getvalue('act')\n", "print('Content-type: text/html\\n')\n", "if VAR_2 == 'checkrestart':\n", "VAR_3 = sql.get_dick_permit(ip=serv)\n", "if VAR_0.getvalue('token') is None:\n", "for VAR_64 in VAR_3:\n", "print('What the fuck?! U r hacker Oo?!')\n", "if VAR_0.getvalue('getcerts') is not None and VAR_1 is not None:\n", "if VAR_64 != '':\n", "sys.exit()\n", "sys.exit()\n", "VAR_4 = sql.get_setting('cert_path')\n", "if VAR_0.getvalue('checkSshConnect') is not None and VAR_1 is not None:\n", "print('ok')\n", "VAR_5 = ['ls -1t ' + VAR_4 + ' |grep pem']\n", "if VAR_0.getvalue('getcert') is not None and VAR_1 is not None:\n", "funct.ssh_command(VAR_1, ['ls -1t'])\n", "print(\n '<div class=\"alert alert-danger\" style=\"margin:0\">Can not connect to the server</div>'\n )\n", "sys.exit()\n", "funct.ssh_command(VAR_1, VAR_5, ip='1')\n", "print(\n '<div class=\"alert alert-danger\" style=\"margin:0\">Can not connect to the server</div>'\n )\n", "VAR_6 = VAR_0.getvalue('getcert')\n", "if VAR_0.getvalue('ssh_cert'):\n", "VAR_4 = sql.get_setting('cert_path')\n", "VAR_7 = VAR_0.getvalue('name')\n", "if VAR_1 and VAR_0.getvalue('ssl_cert'):\n", "VAR_5 = ['cat ' + VAR_4 + '/' + VAR_6]\n", "if not os.path.exists(os.getcwd() + '/keys/'):\n", "VAR_9 = funct.get_config_var('main', 'cert_local_dir')\n", "if VAR_0.getvalue('backend') is not None:\n", "funct.ssh_command(VAR_1, VAR_5, ip='1')\n", "print(\n '<div class=\"alert alert-danger\" style=\"margin:0\">Can not connect to the server</div>'\n )\n", "os.makedirs(os.getcwd() + '/keys/')\n", "VAR_8 = os.path.dirname(os.getcwd()) + '/keys/' + VAR_7 + '.pem'\n", "VAR_4 = sql.get_setting('cert_path')\n", "funct.show_backends(VAR_1)\n", "if VAR_0.getvalue('ip') is not None and VAR_1 is not None:\n", "VAR_79.write(VAR_0.getvalue('ssh_cert'))\n", "print(\n '<div class=\"alert alert-danger\">Can\\'t save ssh keys file. Check ssh keys path in config</div>'\n )\n", "print('<div class=\"alert alert-success\">Ssh key was save into: %s </div>' %\n VAR_8)\n", "if not os.path.exists(VAR_9):\n", "VAR_5 = [\n \"sudo ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $1 }'\"\n ]\n", "if VAR_0.getvalue('showif'):\n", "funct.logging('local', 'users.py#ssh upload new ssh cert %s' % VAR_8)\n", "os.makedirs(VAR_9)\n", "if VAR_0.getvalue('ssl_name') is None:\n", "funct.ssh_command(VAR_1, VAR_5, ip='1')\n", "VAR_5 = [\"sudo ip link|grep 'UP' | awk '{print $2}' |awk -F':' '{print $1}'\"]\n", "if VAR_0.getvalue('action_hap') is not None and VAR_1 is not None:\n", "print('<div class=\"alert alert-danger\">Please enter desired name</div>')\n", "VAR_7 = VAR_0.getvalue('ssl_name') + '.pem'\n", "funct.ssh_command(VAR_1, VAR_5, ip='1')\n", "VAR_11 = VAR_0.getvalue('action_hap')\n", "if VAR_0.getvalue('action_waf') is not None and VAR_1 is not None:\n", "ssl_cert.write(VAR_0.getvalue('ssl_cert'))\n", "print(\n '<div class=\"alert alert-danger\">Can\\'t save ssl keys file. Check ssh keys path in config</div>'\n )\n", "print(\n '<div class=\"alert alert-success\">SSL file was upload to %s into: %s </div>'\n % (VAR_1, VAR_4))\n", "if funct.check_haproxy_config(VAR_1):\n", "VAR_1 = VAR_0.getvalue('serv')\n", "if VAR_2 == 'overview':\n", "VAR_10 = sql.is_master(VAR_1)\n", "VAR_5 = ['sudo systemctl %s haproxy' % VAR_11]\n", "print('Bad config, check please')\n", "VAR_11 = VAR_0.getvalue('action_waf')\n", "ovw.get_overview()\n", "if VAR_2 == 'overviewwaf':\n", "for VAR_45 in VAR_10:\n", "funct.ssh_command(VAR_1, VAR_5)\n", "VAR_5 = ['sudo systemctl %s waf' % VAR_11]\n", "ovw.get_overviewWaf(VAR_0.getvalue('page'))\n", "if VAR_2 == 'overviewServers':\n", "if VAR_45[0] != None:\n", "funct.upload(VAR_1, VAR_4, VAR_7)\n", "os.system('mv %s %s' % (VAR_7, VAR_9))\n", "print('HAproxy was %s' % VAR_11)\n", "funct.ssh_command(VAR_1, VAR_5)\n", "ovw.get_overviewServers()\n", "if VAR_0.getvalue('action'):\n", "funct.upload(VAR_45[0], VAR_4, VAR_7)\n", "funct.logging(VAR_1, 'add.py#ssl upload new ssl cert %s' % VAR_7)\n", "import requests\n", "if VAR_1 is not None and VAR_2 == 'stats':\n", "from requests_toolbelt.utils import dump\n", "import requests\n", "if VAR_1 is not None and VAR_0.getvalue('rows') is not None:\n", "VAR_12 = sql.get_setting('stats_user')\n", "from requests_toolbelt.utils import dump\n", "VAR_20 = VAR_0.getvalue('rows')\n", "if VAR_1 is not None and VAR_0.getvalue('rows1') is not None:\n", "VAR_13 = sql.get_setting('stats_password')\n", "VAR_12 = sql.get_setting('stats_user')\n", "VAR_21 = VAR_0.getvalue('waf')\n", "VAR_20 = VAR_0.getvalue('rows1')\n", "if VAR_0.getvalue('viewlogs') is not None:\n", "VAR_14 = sql.get_setting('stats_port')\n", "VAR_13 = sql.get_setting('stats_password')\n", "VAR_22 = VAR_0.getvalue('grep')\n", "VAR_22 = VAR_0.getvalue('grep')\n", "VAR_33 = VAR_0.getvalue('viewlogs')\n", "if VAR_1 is not None and VAR_2 == 'showMap':\n", "VAR_15 = sql.get_setting('stats_page')\n", "VAR_14 = sql.get_setting('stats_port')\n", "VAR_23 = VAR_0.getvalue('hour')\n", "VAR_23 = VAR_0.getvalue('hour')\n", "VAR_34 = funct.get_config_var('main', 'log_path')\n", "ovw.get_map(VAR_1)\n", "if VAR_0.getvalue('servaction') is not None:\n", "VAR_16 = {'action': VAR_0.getvalue('action'), 's': VAR_0.getvalue('s'), 'b':\n VAR_0.getvalue('b')}\n", "VAR_15 = sql.get_setting('stats_page')\n", "VAR_24 = VAR_0.getvalue('minut')\n", "VAR_24 = VAR_0.getvalue('minut')\n", "VAR_20 = VAR_0.getvalue('rows2')\n", "VAR_36 = sql.get_setting('server_state_file')\n", "if VAR_2 == 'showCompareConfigs':\n", "VAR_17 = {'User-Agent':\n 'Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0',\n 'Accept':\n 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate'}\n", "VAR_72 = requests.get('http://%s:%s/%s' % (VAR_1, VAR_14, VAR_15), auth=(\n haproxy_user, haproxy_pass))\n", "print('Oops. Connection timeout occured!')\n", "VAR_19 = VAR_72.content\n", "VAR_25 = VAR_0.getvalue('hour1')\n", "VAR_25 = VAR_0.getvalue('hour1')\n", "VAR_22 = VAR_0.getvalue('grep')\n", "VAR_37 = sql.get_setting('haproxy_sock')\n", "import glob\n", "if VAR_1 is not None and VAR_0.getvalue('right') is not None:\n", "VAR_18 = requests.post('http://' + VAR_1 + ':' + VAR_14 + '/' + VAR_15,\n VAR_17=headers, VAR_19=postdata, auth=(haproxy_user, haproxy_pass))\n", "print('Oops. Read timeout occured')\n", "print(VAR_19.decode('utf-8'))\n", "VAR_26 = VAR_0.getvalue('minut1')\n", "VAR_26 = VAR_0.getvalue('minut1')\n", "VAR_23 = VAR_0.getvalue('hour')\n", "VAR_38 = VAR_0.getvalue('servaction')\n", "from jinja2 import Environment, FileSystemLoader\n", "from jinja2 import Environment, FileSystemLoader\n", "if VAR_1 is not None and VAR_2 == 'configShow':\n", "print('Http Error:', errh)\n", "VAR_27 = VAR_23 + ':' + VAR_24\n", "VAR_27 = VAR_23 + ':' + VAR_24\n", "VAR_24 = VAR_0.getvalue('minut')\n", "VAR_39 = VAR_0.getvalue('servbackend')\n", "VAR_40 = Environment(loader=FileSystemLoader('templates/ajax'))\n", "VAR_42 = VAR_0.getvalue('left')\n", "VAR_44 = funct.get_config_var('configs', 'haproxy_save_configs_dir')\n", "if VAR_0.getvalue('master'):\n", "print('<div class=\"alert alert-danger\">Error Connecting: %s</div>' % errc)\n", "VAR_28 = VAR_25 + ':' + VAR_26\n", "VAR_28 = VAR_25 + ':' + VAR_26\n", "VAR_25 = VAR_0.getvalue('hour1')\n", "VAR_35 = (\n 'echo \"%s %s\" |sudo socat stdio %s | cut -d \",\" -f 1-2,5-10,18,34-36 | column -s, -t'\n % (VAR_38, VAR_39, VAR_37))\n", "VAR_41 = VAR_40.get_template('/show_compare_configs.html')\n", "VAR_43 = VAR_0.getvalue('right')\n", "if VAR_0.getvalue('configver') is None:\n", "VAR_45 = VAR_0.getvalue('master')\n", "if VAR_0.getvalue('masteradd'):\n", "print('Timeout Error:', errt)\n", "if VAR_22 is not None:\n", "VAR_30 = sql.get_setting('apache_log_path')\n", "VAR_26 = VAR_0.getvalue('minut1')\n", "if VAR_0.getvalue('save') == 'on':\n", "VAR_42 = VAR_0.getvalue('left')\n", "VAR_44 = funct.get_config_var('configs', 'haproxy_save_configs_dir')\n", "VAR_78 = VAR_44 + VAR_1 + '-' + funct.get_data('config') + '.cfg'\n", "VAR_78 = VAR_44 + VAR_0.getvalue('configver')\n", "VAR_46 = VAR_0.getvalue('slave')\n", "VAR_45 = VAR_0.getvalue('masteradd')\n", "if VAR_0.getvalue('haproxyaddserv'):\n", "print('OOps: Something Else', err)\n", "VAR_73 = '|grep'\n", "VAR_73 = ''\n", "if VAR_22 is not None:\n", "VAR_27 = VAR_23 + ':' + VAR_24\n", "VAR_76 = 'echo \"show servers state\" | sudo socat stdio %s > %s' % (VAR_37,\n VAR_36)\n", "VAR_77 = [VAR_35]\n", "VAR_43 = VAR_0.getvalue('right')\n", "VAR_35 = 'diff -ub %s%s %s%s' % (VAR_44, VAR_42, VAR_44, VAR_43)\n", "funct.get_config(VAR_1, VAR_78)\n", "VAR_79 = open(VAR_78, 'r')\n", "print('<div class=\"alert alert-danger\">Can\\'t read import config file</div>')\n", "from jinja2 import Environment, FileSystemLoader\n", "VAR_47 = VAR_0.getvalue('interface')\n", "VAR_46 = VAR_0.getvalue('slaveadd')\n", "funct.install_haproxy(VAR_0.getvalue('haproxyaddserv'), syn_flood=form.\n getvalue('syn_flood'))\n", "if VAR_0.getvalue('installwaf'):\n", "VAR_29 = sql.get_setting('syslog_server_enable')\n", "VAR_22 = ''\n", "VAR_73 = '|grep'\n", "VAR_73 = ''\n", "VAR_28 = VAR_25 + ':' + VAR_26\n", "VAR_77 = [VAR_35, VAR_76]\n", "if VAR_38 != 'show':\n", "VAR_41 = VAR_41.render(VAR_1=serv, VAR_43=right, VAR_42=left, return_files=\n funct.get_files())\n", "VAR_40 = Environment(loader=FileSystemLoader('templates/ajax'), extensions=\n ['jinja2.ext.loopcontrols', 'jinja2.ext.do'])\n", "VAR_40 = Environment(loader=FileSystemLoader('templates/ajax'), extensions=\n ['jinja2.ext.loopcontrols'])\n", "VAR_48 = VAR_0.getvalue('vrrpip')\n", "VAR_47 = VAR_0.getvalue('interfaceadd')\n", "funct.waf_install(VAR_0.getvalue('installwaf'))\n", "if VAR_0.getvalue('metrics_waf'):\n", "if VAR_29 is None or VAR_29 == '0':\n", "if VAR_1 == 'haproxy-wi.access.log':\n", "VAR_22 = ''\n", "if VAR_22 is not None:\n", "print('string' % (VAR_38, VAR_39, VAR_1, VAR_1))\n", "funct.ssh_command(VAR_1, VAR_77, show_log='1')\n", "print(VAR_41)\n", "VAR_41 = VAR_40.get_template('compare.html')\n", "VAR_41 = VAR_40.get_template('config_show.html')\n", "VAR_49 = sql.get_setting('tmp_config_path')\n", "VAR_48 = VAR_0.getvalue('vrrpipadd')\n", "sql.update_waf_metrics_enable(VAR_0.getvalue('metrics_waf'), VAR_0.getvalue\n ('enable'))\n", "if VAR_0.getvalue('table_metrics'):\n", "VAR_74 = sql.get_setting('local_path_logs')\n", "VAR_5 = [\n \"sudo cat /var/log/%s/syslog.log | sed '/ %s:00/,/ %s:00/! d' |tail -%s %s %s\"\n % (VAR_1, VAR_27, VAR_28, VAR_20, VAR_73, VAR_22)]\n", "VAR_35 = (\n 'cat %s| awk -F\"/|:\" \\'$3>\"%s:00\" && $3<\"%s:00\"\\' |tail -%s %s %s' % (\n VAR_30 + '/' + VAR_1, VAR_27, VAR_28, VAR_20, VAR_73, VAR_22))\n", "VAR_35 = 'cat %s| awk \\'$4>\"%s:00\" && $4<\"%s:00\"\\' |tail -%s %s %s' % (\n VAR_30 + '/' + VAR_1, VAR_27, VAR_28, VAR_20, VAR_73, VAR_22)\n", "VAR_73 = '|grep'\n", "VAR_73 = ''\n", "VAR_11 = 'edit.py ' + VAR_38 + ' ' + VAR_39\n", "VAR_31, VAR_32 = funct.subprocess_execute(VAR_35)\n", "VAR_41 = VAR_41.render(VAR_79=conf, view=form.getvalue('view'), VAR_1=serv,\n configver=form.getvalue('configver'), role=funct.is_admin(level=2))\n", "VAR_50 = 'install_keepalived.sh'\n", "VAR_52 = VAR_0.getvalue('kp')\n", "import http.cookies\n", "if VAR_0.getvalue('metrics'):\n", "VAR_75 = VAR_1\n", "VAR_75 = sql.get_setting('syslog_server')\n", "VAR_31, VAR_32 = funct.subprocess_execute(VAR_35)\n", "VAR_35 = 'cat %s| awk \\'$3>\"%s:00\" && $3<\"%s:00\"\\' |tail -%s %s %s' % (\n VAR_34 + VAR_33, VAR_27, VAR_28, VAR_20, VAR_73, VAR_22)\n", "VAR_22 = ''\n", "funct.logging(VAR_1, VAR_11)\n", "VAR_41 = VAR_41.render(stdout=output)\n", "print(VAR_41)\n", "if VAR_0.getvalue('hap') == '1':\n", "VAR_49 = sql.get_setting('tmp_config_path')\n", "from jinja2 import Environment, FileSystemLoader\n", "from datetime import timedelta\n", "if VAR_0.getvalue('waf_metrics'):\n", "VAR_5 = ['sudo cat %s| awk \\'$3>\"%s:00\" && $3<\"%s:00\"\\' |tail -%s %s %s' %\n (VAR_74, VAR_27, VAR_28, VAR_20, VAR_73, VAR_22)]\n", "if VAR_21 == '1':\n", "funct.show_log(VAR_31)\n", "VAR_31, VAR_32 = funct.subprocess_execute(VAR_35)\n", "print(VAR_41)\n", "if VAR_0.getvalue('configver') is None:\n", "funct.install_haproxy(VAR_45)\n", "if VAR_0.getvalue('syn_flood') == '1':\n", "VAR_50 = 'add_vrrp.sh'\n", "VAR_40 = Environment(loader=FileSystemLoader('templates/ajax'))\n", "from bokeh.plotting import figure, output_file, show\n", "from datetime import timedelta\n", "if VAR_0.getvalue('get_hap_v'):\n", "VAR_74 = '/var/log/modsec_audit.log'\n", "funct.ssh_command(VAR_75, VAR_5, show_log='1')\n", "print(VAR_32)\n", "funct.show_log(VAR_31)\n", "print(VAR_32)\n", "os.system('/bin/rm -f ' + VAR_78)\n", "funct.install_haproxy(VAR_46)\n", "funct.syn_flood_protect(VAR_45)\n", "os.system('cp scripts/%s .' % VAR_50)\n", "os.system('cp scripts/%s .' % VAR_50)\n", "VAR_41 = VAR_40.get_template('table_metrics.html')\n", "from bokeh.models import ColumnDataSource, HoverTool, DatetimeTickFormatter, DatePicker\n", "from bokeh.plotting import figure, output_file, show\n", "VAR_31 = funct.check_haproxy_version(VAR_1)\n", "if VAR_0.getvalue('bwlists'):\n", "VAR_5 = ['sudo cat %s |tail -%s %s %s' % (VAR_74, VAR_20, VAR_73, VAR_22)]\n", "print(VAR_32)\n", "funct.syn_flood_protect(VAR_46)\n", "VAR_51 = str(funct.upload(VAR_45, VAR_49, VAR_50))\n", "VAR_51 = str(funct.upload(VAR_45, VAR_49, VAR_50))\n", "VAR_53 = http.cookies.SimpleCookie(os.environ.get('HTTP_COOKIE'))\n", "from bokeh.layouts import widgetbox, gridplot\n", "from bokeh.models import ColumnDataSource, HoverTool, DatetimeTickFormatter, DatePicker\n", "print(VAR_31)\n", "VAR_59 = os.path.dirname(os.getcwd()) + '/' + sql.get_setting('lists_path'\n ) + '/' + VAR_0.getvalue('group') + '/' + VAR_0.getvalue('color'\n ) + '/' + VAR_0.getvalue('bwlists')\n", "if VAR_0.getvalue('bwlists_create'):\n", "if VAR_51:\n", "if VAR_51:\n", "VAR_54 = VAR_53.get('uuid')\n", "from bokeh.models.widgets import Button, RadioButtonGroup, Select\n", "from bokeh.layouts import widgetbox, gridplot\n", "VAR_87 = open(VAR_59, 'r')\n", "print('<div class=\"alert alert-danger\" style=\"margin:0\">Cat\\'n read ' +\n VAR_0.getvalue('color') + ' list</div>')\n", "VAR_60 = VAR_0.getvalue('bwlists_create').split('.')[0]\n", "if VAR_0.getvalue('bwlists_save'):\n", "print('error: ' + VAR_51)\n", "funct.upload(VAR_46, VAR_49, VAR_50)\n", "print('error: ' + VAR_51)\n", "funct.upload(VAR_46, VAR_49, VAR_50)\n", "VAR_55 = sql.select_table_metrics(VAR_54.value)\n", "import pandas as pd\n", "from bokeh.models.widgets import Button, RadioButtonGroup, Select\n", "VAR_88 = VAR_87.read()\n", "VAR_60 += '.lst'\n", "VAR_59 = os.path.dirname(os.getcwd()) + '/' + sql.get_setting('lists_path'\n ) + '/' + VAR_0.getvalue('group') + '/' + VAR_0.getvalue('color'\n ) + '/' + VAR_0.getvalue('bwlists_save')\n", "if VAR_0.getvalue('get_lists'):\n", "sys.exit()\n", "funct.ssh_command(VAR_45, ['sudo chmod +x ' + VAR_49 + VAR_50, VAR_49 +\n VAR_50 + ' MASTER ' + VAR_47 + ' ' + VAR_48])\n", "sys.exit()\n", "funct.ssh_command(VAR_45, ['sudo chmod +x ' + VAR_49 + VAR_50, VAR_49 +\n VAR_50 + ' MASTER ' + VAR_47 + ' ' + VAR_48 + ' ' + VAR_52])\n", "VAR_41 = VAR_41.render(VAR_55=sql.select_table_metrics(user_id.value))\n", "import http.cookies\n", "import pandas as pd\n", "VAR_87.close\n", "VAR_59 = os.path.dirname(os.getcwd()) + '/' + sql.get_setting('lists_path'\n ) + '/' + VAR_0.getvalue('group') + '/' + VAR_0.getvalue('color'\n ) + '/' + VAR_60\n", "VAR_87.write(VAR_0.getvalue('bwlists_content'))\n", "print('<div class=\"alert alert-danger\" style=\"margin:0\">Cat\\'n save ' +\n VAR_0.getvalue('color') + ' list. %s </div>' % e)\n", "VAR_3 = sql.get_dick_permit()\n", "VAR_59 = os.path.dirname(os.getcwd()) + '/' + sql.get_setting('lists_path'\n ) + '/' + VAR_0.getvalue('group') + '/' + VAR_0.getvalue('color')\n", "if VAR_0.getvalue('get_ldap_email'):\n", "funct.ssh_command(VAR_46, ['sudo chmod +x ' + VAR_49 + VAR_50, VAR_49 +\n VAR_50 + ' BACKUP ' + VAR_47 + ' ' + VAR_48])\n", "funct.ssh_command(VAR_46, ['sudo chmod +x ' + VAR_49 + VAR_50, VAR_49 +\n VAR_50 + ' BACKUP ' + VAR_47 + ' ' + VAR_48 + ' ' + VAR_52])\n", "print(VAR_41)\n", "VAR_53 = http.cookies.SimpleCookie(os.environ.get('HTTP_COOKIE'))\n", "import http.cookies\n", "print(VAR_88)\n", "open(VAR_59, 'a').close()\n", "print('<div class=\"alert alert-danger\" style=\"margin:0\">Cat\\'n create new ' +\n VAR_0.getvalue('color') + ' list. %s </div>' % e)\n", "VAR_61 = sql.get_setting('haproxy_dir') + '/' + VAR_0.getvalue('color')\n", "VAR_62 = funct.get_files(dir=list, format='lst')\n", "VAR_63 = VAR_0.getvalue('get_ldap_email')\n", "os.system('rm -f %s' % VAR_50)\n", "os.system('rm -f %s' % VAR_50)\n", "VAR_54 = VAR_53.get('uuid')\n", "VAR_53 = http.cookies.SimpleCookie(os.environ.get('HTTP_COOKIE'))\n", "print('<div class=\"alert alert-success\" style=\"margin:0\">' + VAR_0.getvalue\n ('color') + ' list was created</div>')\n", "for VAR_64 in VAR_3:\n", "for VAR_59 in VAR_62:\n", "import ldap\n", "sql.update_server_master(VAR_45, VAR_46)\n", "VAR_3 = sql.select_servers_metrics(VAR_54.value)\n", "VAR_54 = VAR_53.get('uuid')\n", "funct.ssh_command(VAR_64[2], ['sudo mkdir ' + VAR_61])\n", "print(VAR_59)\n", "VAR_64 = sql.get_setting('ldap_server')\n", "VAR_3 = sorted(VAR_3)\n", "VAR_3 = sql.select_waf_servers_metrics(VAR_54.value)\n", "VAR_51 = funct.upload(VAR_64[2], VAR_61 + '/' + VAR_0.getvalue(\n 'bwlists_save'), VAR_59, dir='fullpath')\n", "VAR_65 = sql.get_setting('ldap_port')\n", "VAR_56 = {}\n", "VAR_3 = sorted(VAR_3)\n", "if VAR_51:\n", "VAR_66 = sql.get_setting('ldap_user')\n", "for VAR_1 in VAR_3:\n", "VAR_56 = {}\n", "print('<div class=\"alert alert-danger\">Upload fail: %s</div>' % VAR_51)\n", "print('<div class=\"alert alert-success\" style=\"margin:10px\">Edited ' +\n VAR_0.getvalue('color') + ' list was uploaded to ' + VAR_64[1] + '</div>')\n", "VAR_67 = sql.get_setting('ldap_password')\n", "VAR_1 = VAR_1[0]\n", "VAR_57 = []\n", "for VAR_1 in VAR_3:\n", "if VAR_0.getvalue('bwlists_restart') == 'restart':\n", "VAR_68 = sql.get_setting('ldap_base')\n", "VAR_56[VAR_1] = {}\n", "for key, value in VAR_56.items():\n", "VAR_1 = VAR_1[0]\n", "VAR_57 = []\n", "funct.ssh_command(VAR_64[2], ['sudo ' + sql.get_setting('restart_command')])\n", "VAR_69 = sql.get_setting('ldap_domain')\n", "VAR_80 = sql.select_metrics(VAR_1)\n", "VAR_57.append(value)\n", "VAR_58 = gridplot(VAR_57, ncols=2, plot_width=800, plot_height=250,\n toolbar_location='left', toolbar_options=dict(logo=None))\n", "VAR_56[VAR_1] = {}\n", "for key, value in VAR_56.items():\n", "VAR_70 = sql.get_setting('ldap_search_field')\n", "VAR_81 = {}\n", "show(VAR_58)\n", "VAR_80 = sql.select_waf_metrics(VAR_1)\n", "VAR_57.append(value)\n", "VAR_58 = gridplot(VAR_57, ncols=2, plot_width=800, plot_height=250,\n toolbar_location='left', toolbar_options=dict(logo=None))\n", "VAR_71 = ldap.initialize('ldap://' + VAR_64 + ':' + VAR_65)\n", "for i in VAR_80:\n", "VAR_81 = {}\n", "show(VAR_58)\n", "VAR_71.protocol_version = ldap.VERSION3\n", "VAR_71.unbind()\n", "VAR_94 = str(i[5])\n", "VAR_82 = pd.DataFrame.from_dict(VAR_81, orient='index')\n", "for i in VAR_80:\n", "VAR_71.set_option(ldap.OPT_REFERRALS, 0)\n", "VAR_81[VAR_94] = {}\n", "VAR_82 = VAR_82.fillna(0)\n", "VAR_94 = str(i[2])\n", "VAR_82 = pd.DataFrame.from_dict(VAR_81, orient='index')\n", "VAR_89 = VAR_71.simple_bind_s(VAR_66, VAR_67)\n", "VAR_81[VAR_94]['server'] = str(i[0])\n", "VAR_82.index = pd.to_datetime(VAR_82.index)\n", "VAR_81[VAR_94] = {}\n", "VAR_82 = VAR_82.fillna(0)\n", "VAR_90 = '(&(objectClass=user)(sAMAccountName=' + VAR_63 + '))'\n", "VAR_81[VAR_94]['curr_con'] = str(i[1])\n", "VAR_82.index.name = 'Date'\n", "VAR_81[VAR_94]['conn'] = str(i[1])\n", "VAR_82.index = pd.to_datetime(VAR_82.index)\n", "VAR_91 = [VAR_70]\n", "VAR_81[VAR_94]['curr_ssl_con'] = str(i[2])\n", "VAR_82.sort_index(inplace=True)\n", "VAR_82.index.name = 'Date'\n", "VAR_92 = VAR_71.search_s(VAR_68, ldap.SCOPE_SUBTREE, VAR_90, VAR_91)\n", "VAR_81[VAR_94]['sess_rate'] = str(i[3])\n", "VAR_83 = ColumnDataSource(VAR_82)\n", "VAR_82.sort_index(inplace=True)\n", "VAR_93 = [entry for dn, entry in VAR_92 if isinstance(entry, dict)]\n", "VAR_81[VAR_94]['max_sess_rate'] = str(i[4])\n", "output_file('templates/metrics_out.html', mode='inline')\n", "VAR_83 = ColumnDataSource(VAR_82)\n", "print('[\"' + VAR_93[0][VAR_70][0].decode('utf-8') + '\",\"' + VAR_69 + '\"]')\n", "print('error: user not found')\n", "VAR_84 = VAR_82.index.min() - pd.Timedelta(hours=1)\n", "output_file('templates/metrics_waf_out.html', mode='inline')\n", "VAR_85 = VAR_82.index.max() + pd.Timedelta(minutes=1)\n", "VAR_84 = VAR_82.index.min() - pd.Timedelta(hours=1)\n", "VAR_56[VAR_1] = figure(tools='pan,box_zoom,reset,xwheel_zoom', title=metric\n [0][0], x_axis_type='datetime', y_axis_label='Connections', x_range=(\n x_max.timestamp() * 1000 - 60 * 100000, x_max.timestamp() * 1000))\n", "VAR_85 = VAR_82.index.max() + pd.Timedelta(minutes=1)\n", "VAR_86 = HoverTool(tooltips=[('Connections', '@curr_con'), (\n 'SSL connections', '@curr_ssl_con'), ('Sessions rate', '@sess_rate')],\n mode='mouse')\n", "VAR_56[VAR_1] = figure(tools='pan,box_zoom,reset,xwheel_zoom', title=metric\n [0][0], x_axis_type='datetime', y_axis_label='Connections', x_range=(\n x_max.timestamp() * 1000 - 60 * 100000, x_max.timestamp() * 1000))\n", "VAR_56[VAR_1].ygrid.band_fill_color = '#f3f8fb'\n", "VAR_86 = HoverTool(tooltips=[('Connections', '@conn')], mode='mouse')\n", "VAR_56[VAR_1].ygrid.band_fill_alpha = 0.9\n", "VAR_56[VAR_1].ygrid.band_fill_color = '#f3f8fb'\n", "VAR_56[VAR_1].y_range.start = 0\n", "VAR_56[VAR_1].ygrid.band_fill_alpha = 0.9\n", "VAR_56[VAR_1].y_range.end = int(VAR_82['curr_con'].max()) + 150\n", "VAR_56[VAR_1].y_range.start = 0\n", "VAR_56[VAR_1].add_tools(VAR_86)\n", "VAR_56[VAR_1].y_range.end = int(VAR_82['conn'].max()) + 150\n", "VAR_56[VAR_1].title.text_font_size = '20px'\n", "VAR_56[VAR_1].add_tools(VAR_86)\n", "VAR_56[VAR_1].line('Date', 'curr_con', VAR_83=source, alpha=0.5, color=\n '#5cb85c', line_width=2, legend='Conn')\n", "VAR_56[VAR_1].title.text_font_size = '20px'\n", "VAR_56[VAR_1].line('Date', 'curr_ssl_con', VAR_83=source, alpha=0.5, color=\n '#5d9ceb', line_width=2, legend='SSL con')\n", "VAR_56[VAR_1].line('Date', 'conn', VAR_83=source, alpha=0.5, color=\n '#5cb85c', line_width=2, legend='Conn')\n", "VAR_56[VAR_1].line('Date', 'sess_rate', VAR_83=source, alpha=0.5, color=\n '#33414e', line_width=2, legend='Sessions')\n", "VAR_56[VAR_1].legend.orientation = 'horizontal'\n", "VAR_56[VAR_1].legend.orientation = 'horizontal'\n", "VAR_56[VAR_1].legend.location = 'top_left'\n", "VAR_56[VAR_1].legend.location = 'top_left'\n", "VAR_56[VAR_1].legend.padding = 5\n", "VAR_56[VAR_1].legend.padding = 5\n" ]
[ "import cgi\n", "import os, sys\n", "import funct\n", "import sql\n", "import ovw\n", "form = cgi.FieldStorage()\n", "serv = form.getvalue('serv')\n", "act = form.getvalue('act')\n", "print('Content-type: text/html\\n')\n", "if act == 'checkrestart':\n", "servers = sql.get_dick_permit(ip=serv)\n", "if form.getvalue('token') is None:\n", "for server in servers:\n", "print('What the fuck?! U r hacker Oo?!')\n", "if form.getvalue('getcerts') is not None and serv is not None:\n", "if server != '':\n", "sys.exit()\n", "sys.exit()\n", "cert_path = sql.get_setting('cert_path')\n", "if form.getvalue('checkSshConnect') is not None and serv is not None:\n", "print('ok')\n", "commands = ['ls -1t ' + cert_path + ' |grep pem']\n", "if form.getvalue('getcert') is not None and serv is not None:\n", "funct.ssh_command(serv, ['ls -1t'])\n", "print(\n '<div class=\"alert alert-danger\" style=\"margin:0\">Can not connect to the server</div>'\n )\n", "sys.exit()\n", "funct.ssh_command(serv, commands, ip='1')\n", "print(\n '<div class=\"alert alert-danger\" style=\"margin:0\">Can not connect to the server</div>'\n )\n", "id = form.getvalue('getcert')\n", "if form.getvalue('ssh_cert'):\n", "cert_path = sql.get_setting('cert_path')\n", "name = form.getvalue('name')\n", "if serv and form.getvalue('ssl_cert'):\n", "commands = ['cat ' + cert_path + '/' + id]\n", "if not os.path.exists(os.getcwd() + '/keys/'):\n", "cert_local_dir = funct.get_config_var('main', 'cert_local_dir')\n", "if form.getvalue('backend') is not None:\n", "funct.ssh_command(serv, commands, ip='1')\n", "print(\n '<div class=\"alert alert-danger\" style=\"margin:0\">Can not connect to the server</div>'\n )\n", "os.makedirs(os.getcwd() + '/keys/')\n", "ssh_keys = os.path.dirname(os.getcwd()) + '/keys/' + name + '.pem'\n", "cert_path = sql.get_setting('cert_path')\n", "funct.show_backends(serv)\n", "if form.getvalue('ip') is not None and serv is not None:\n", "conf.write(form.getvalue('ssh_cert'))\n", "print(\n '<div class=\"alert alert-danger\">Can\\'t save ssh keys file. Check ssh keys path in config</div>'\n )\n", "print('<div class=\"alert alert-success\">Ssh key was save into: %s </div>' %\n ssh_keys)\n", "if not os.path.exists(cert_local_dir):\n", "commands = [\n \"sudo ip a |grep inet |egrep -v '::1' |awk '{ print $2 }' |awk -F'/' '{ print $1 }'\"\n ]\n", "if form.getvalue('showif'):\n", "funct.logging('local', 'users.py#ssh upload new ssh cert %s' % ssh_keys)\n", "os.makedirs(cert_local_dir)\n", "if form.getvalue('ssl_name') is None:\n", "funct.ssh_command(serv, commands, ip='1')\n", "commands = [\n \"sudo ip link|grep 'UP' | awk '{print $2}' |awk -F':' '{print $1}'\"]\n", "if form.getvalue('action_hap') is not None and serv is not None:\n", "print('<div class=\"alert alert-danger\">Please enter desired name</div>')\n", "name = form.getvalue('ssl_name') + '.pem'\n", "funct.ssh_command(serv, commands, ip='1')\n", "action = form.getvalue('action_hap')\n", "if form.getvalue('action_waf') is not None and serv is not None:\n", "ssl_cert.write(form.getvalue('ssl_cert'))\n", "print(\n '<div class=\"alert alert-danger\">Can\\'t save ssl keys file. Check ssh keys path in config</div>'\n )\n", "print(\n '<div class=\"alert alert-success\">SSL file was upload to %s into: %s </div>'\n % (serv, cert_path))\n", "if funct.check_haproxy_config(serv):\n", "serv = form.getvalue('serv')\n", "if act == 'overview':\n", "MASTERS = sql.is_master(serv)\n", "commands = ['sudo systemctl %s haproxy' % action]\n", "print('Bad config, check please')\n", "action = form.getvalue('action_waf')\n", "ovw.get_overview()\n", "if act == 'overviewwaf':\n", "for master in MASTERS:\n", "funct.ssh_command(serv, commands)\n", "commands = ['sudo systemctl %s waf' % action]\n", "ovw.get_overviewWaf(form.getvalue('page'))\n", "if act == 'overviewServers':\n", "if master[0] != None:\n", "funct.upload(serv, cert_path, name)\n", "os.system('mv %s %s' % (name, cert_local_dir))\n", "print('HAproxy was %s' % action)\n", "funct.ssh_command(serv, commands)\n", "ovw.get_overviewServers()\n", "if form.getvalue('action'):\n", "funct.upload(master[0], cert_path, name)\n", "funct.logging(serv, 'add.py#ssl upload new ssl cert %s' % name)\n", "import requests\n", "if serv is not None and act == 'stats':\n", "from requests_toolbelt.utils import dump\n", "import requests\n", "if serv is not None and form.getvalue('rows') is not None:\n", "haproxy_user = sql.get_setting('stats_user')\n", "from requests_toolbelt.utils import dump\n", "rows = form.getvalue('rows')\n", "if serv is not None and form.getvalue('rows1') is not None:\n", "haproxy_pass = sql.get_setting('stats_password')\n", "haproxy_user = sql.get_setting('stats_user')\n", "waf = form.getvalue('waf')\n", "rows = form.getvalue('rows1')\n", "if form.getvalue('viewlogs') is not None:\n", "stats_port = sql.get_setting('stats_port')\n", "haproxy_pass = sql.get_setting('stats_password')\n", "grep = form.getvalue('grep')\n", "grep = form.getvalue('grep')\n", "viewlog = form.getvalue('viewlogs')\n", "if serv is not None and act == 'showMap':\n", "stats_page = sql.get_setting('stats_page')\n", "stats_port = sql.get_setting('stats_port')\n", "hour = form.getvalue('hour')\n", "hour = form.getvalue('hour')\n", "log_path = funct.get_config_var('main', 'log_path')\n", "ovw.get_map(serv)\n", "if form.getvalue('servaction') is not None:\n", "postdata = {'action': form.getvalue('action'), 's': form.getvalue('s'), 'b':\n form.getvalue('b')}\n", "stats_page = sql.get_setting('stats_page')\n", "minut = form.getvalue('minut')\n", "minut = form.getvalue('minut')\n", "rows = form.getvalue('rows2')\n", "server_state_file = sql.get_setting('server_state_file')\n", "if act == 'showCompareConfigs':\n", "headers = {'User-Agent':\n 'Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0',\n 'Accept':\n 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate'}\n", "response = requests.get('http://%s:%s/%s' % (serv, stats_port, stats_page),\n auth=(haproxy_user, haproxy_pass))\n", "print('Oops. Connection timeout occured!')\n", "data = response.content\n", "hour1 = form.getvalue('hour1')\n", "hour1 = form.getvalue('hour1')\n", "grep = form.getvalue('grep')\n", "haproxy_sock = sql.get_setting('haproxy_sock')\n", "import glob\n", "if serv is not None and form.getvalue('right') is not None:\n", "q = requests.post('http://' + serv + ':' + stats_port + '/' + stats_page,\n headers=headers, data=postdata, auth=(haproxy_user, haproxy_pass))\n", "print('Oops. Read timeout occured')\n", "print(data.decode('utf-8'))\n", "minut1 = form.getvalue('minut1')\n", "minut1 = form.getvalue('minut1')\n", "hour = form.getvalue('hour')\n", "enable = form.getvalue('servaction')\n", "from jinja2 import Environment, FileSystemLoader\n", "from jinja2 import Environment, FileSystemLoader\n", "if serv is not None and act == 'configShow':\n", "print('Http Error:', errh)\n", "date = hour + ':' + minut\n", "date = hour + ':' + minut\n", "minut = form.getvalue('minut')\n", "backend = form.getvalue('servbackend')\n", "env = Environment(loader=FileSystemLoader('templates/ajax'))\n", "left = form.getvalue('left')\n", "hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')\n", "if form.getvalue('master'):\n", "print('<div class=\"alert alert-danger\">Error Connecting: %s</div>' % errc)\n", "date1 = hour1 + ':' + minut1\n", "date1 = hour1 + ':' + minut1\n", "hour1 = form.getvalue('hour1')\n", "cmd = (\n 'echo \"%s %s\" |sudo socat stdio %s | cut -d \",\" -f 1-2,5-10,18,34-36 | column -s, -t'\n % (enable, backend, haproxy_sock))\n", "template = env.get_template('/show_compare_configs.html')\n", "right = form.getvalue('right')\n", "if form.getvalue('configver') is None:\n", "master = form.getvalue('master')\n", "if form.getvalue('masteradd'):\n", "print('Timeout Error:', errt)\n", "if grep is not None:\n", "apache_log_path = sql.get_setting('apache_log_path')\n", "minut1 = form.getvalue('minut1')\n", "if form.getvalue('save') == 'on':\n", "left = form.getvalue('left')\n", "hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')\n", "cfg = hap_configs_dir + serv + '-' + funct.get_data('config') + '.cfg'\n", "cfg = hap_configs_dir + form.getvalue('configver')\n", "slave = form.getvalue('slave')\n", "master = form.getvalue('masteradd')\n", "if form.getvalue('haproxyaddserv'):\n", "print('OOps: Something Else', err)\n", "grep_act = '|grep'\n", "grep_act = ''\n", "if grep is not None:\n", "date = hour + ':' + minut\n", "save_command = 'echo \"show servers state\" | sudo socat stdio %s > %s' % (\n haproxy_sock, server_state_file)\n", "command = [cmd]\n", "right = form.getvalue('right')\n", "cmd = 'diff -ub %s%s %s%s' % (hap_configs_dir, left, hap_configs_dir, right)\n", "funct.get_config(serv, cfg)\n", "conf = open(cfg, 'r')\n", "print('<div class=\"alert alert-danger\">Can\\'t read import config file</div>')\n", "from jinja2 import Environment, FileSystemLoader\n", "interface = form.getvalue('interface')\n", "slave = form.getvalue('slaveadd')\n", "funct.install_haproxy(form.getvalue('haproxyaddserv'), syn_flood=form.\n getvalue('syn_flood'))\n", "if form.getvalue('installwaf'):\n", "syslog_server_enable = sql.get_setting('syslog_server_enable')\n", "grep = ''\n", "grep_act = '|grep'\n", "grep_act = ''\n", "date1 = hour1 + ':' + minut1\n", "command = [cmd, save_command]\n", "if enable != 'show':\n", "template = template.render(serv=serv, right=right, left=left, return_files=\n funct.get_files())\n", "env = Environment(loader=FileSystemLoader('templates/ajax'), extensions=[\n 'jinja2.ext.loopcontrols', 'jinja2.ext.do'])\n", "env = Environment(loader=FileSystemLoader('templates/ajax'), extensions=[\n 'jinja2.ext.loopcontrols'])\n", "vrrpip = form.getvalue('vrrpip')\n", "interface = form.getvalue('interfaceadd')\n", "funct.waf_install(form.getvalue('installwaf'))\n", "if form.getvalue('metrics_waf'):\n", "if syslog_server_enable is None or syslog_server_enable == '0':\n", "if serv == 'haproxy-wi.access.log':\n", "grep = ''\n", "if grep is not None:\n", "print(\n '<center><h3>You %s %s on HAproxy %s. <a href=\"viewsttats.py?serv=%s\" title=\"View stat\" target=\"_blank\">Look it</a> or <a href=\"edit.py\" title=\"Edit\">Edit something else</a></h3><br />'\n % (enable, backend, serv, serv))\n", "funct.ssh_command(serv, command, show_log='1')\n", "print(template)\n", "template = env.get_template('compare.html')\n", "template = env.get_template('config_show.html')\n", "tmp_config_path = sql.get_setting('tmp_config_path')\n", "vrrpip = form.getvalue('vrrpipadd')\n", "sql.update_waf_metrics_enable(form.getvalue('metrics_waf'), form.getvalue(\n 'enable'))\n", "if form.getvalue('table_metrics'):\n", "local_path_logs = sql.get_setting('local_path_logs')\n", "commands = [\n \"sudo cat /var/log/%s/syslog.log | sed '/ %s:00/,/ %s:00/! d' |tail -%s %s %s\"\n % (serv, date, date1, rows, grep_act, grep)]\n", "cmd = 'cat %s| awk -F\"/|:\" \\'$3>\"%s:00\" && $3<\"%s:00\"\\' |tail -%s %s %s' % (\n apache_log_path + '/' + serv, date, date1, rows, grep_act, grep)\n", "cmd = 'cat %s| awk \\'$4>\"%s:00\" && $4<\"%s:00\"\\' |tail -%s %s %s' % (\n apache_log_path + '/' + serv, date, date1, rows, grep_act, grep)\n", "grep_act = '|grep'\n", "grep_act = ''\n", "action = 'edit.py ' + enable + ' ' + backend\n", "output, stderr = funct.subprocess_execute(cmd)\n", "template = template.render(conf=conf, view=form.getvalue('view'), serv=serv,\n configver=form.getvalue('configver'), role=funct.is_admin(level=2))\n", "script = 'install_keepalived.sh'\n", "kp = form.getvalue('kp')\n", "import http.cookies\n", "if form.getvalue('metrics'):\n", "syslog_server = serv\n", "syslog_server = sql.get_setting('syslog_server')\n", "output, stderr = funct.subprocess_execute(cmd)\n", "cmd = 'cat %s| awk \\'$3>\"%s:00\" && $3<\"%s:00\"\\' |tail -%s %s %s' % (\n log_path + viewlog, date, date1, rows, grep_act, grep)\n", "grep = ''\n", "funct.logging(serv, action)\n", "template = template.render(stdout=output)\n", "print(template)\n", "if form.getvalue('hap') == '1':\n", "tmp_config_path = sql.get_setting('tmp_config_path')\n", "from jinja2 import Environment, FileSystemLoader\n", "from datetime import timedelta\n", "if form.getvalue('waf_metrics'):\n", "commands = [\n 'sudo cat %s| awk \\'$3>\"%s:00\" && $3<\"%s:00\"\\' |tail -%s %s %s' % (\n local_path_logs, date, date1, rows, grep_act, grep)]\n", "if waf == '1':\n", "funct.show_log(output)\n", "output, stderr = funct.subprocess_execute(cmd)\n", "print(template)\n", "if form.getvalue('configver') is None:\n", "funct.install_haproxy(master)\n", "if form.getvalue('syn_flood') == '1':\n", "script = 'add_vrrp.sh'\n", "env = Environment(loader=FileSystemLoader('templates/ajax'))\n", "from bokeh.plotting import figure, output_file, show\n", "from datetime import timedelta\n", "if form.getvalue('get_hap_v'):\n", "local_path_logs = '/var/log/modsec_audit.log'\n", "funct.ssh_command(syslog_server, commands, show_log='1')\n", "print(stderr)\n", "funct.show_log(output)\n", "print(stderr)\n", "os.system('/bin/rm -f ' + cfg)\n", "funct.install_haproxy(slave)\n", "funct.syn_flood_protect(master)\n", "os.system('cp scripts/%s .' % script)\n", "os.system('cp scripts/%s .' % script)\n", "template = env.get_template('table_metrics.html')\n", "from bokeh.models import ColumnDataSource, HoverTool, DatetimeTickFormatter, DatePicker\n", "from bokeh.plotting import figure, output_file, show\n", "output = funct.check_haproxy_version(serv)\n", "if form.getvalue('bwlists'):\n", "commands = ['sudo cat %s |tail -%s %s %s' % (local_path_logs, rows,\n grep_act, grep)]\n", "print(stderr)\n", "funct.syn_flood_protect(slave)\n", "error = str(funct.upload(master, tmp_config_path, script))\n", "error = str(funct.upload(master, tmp_config_path, script))\n", "cookie = http.cookies.SimpleCookie(os.environ.get('HTTP_COOKIE'))\n", "from bokeh.layouts import widgetbox, gridplot\n", "from bokeh.models import ColumnDataSource, HoverTool, DatetimeTickFormatter, DatePicker\n", "print(output)\n", "list = os.path.dirname(os.getcwd()) + '/' + sql.get_setting('lists_path'\n ) + '/' + form.getvalue('group') + '/' + form.getvalue('color'\n ) + '/' + form.getvalue('bwlists')\n", "if form.getvalue('bwlists_create'):\n", "if error:\n", "if error:\n", "user_id = cookie.get('uuid')\n", "from bokeh.models.widgets import Button, RadioButtonGroup, Select\n", "from bokeh.layouts import widgetbox, gridplot\n", "file = open(list, 'r')\n", "print('<div class=\"alert alert-danger\" style=\"margin:0\">Cat\\'n read ' +\n form.getvalue('color') + ' list</div>')\n", "list_name = form.getvalue('bwlists_create').split('.')[0]\n", "if form.getvalue('bwlists_save'):\n", "print('error: ' + error)\n", "funct.upload(slave, tmp_config_path, script)\n", "print('error: ' + error)\n", "funct.upload(slave, tmp_config_path, script)\n", "table_stat = sql.select_table_metrics(user_id.value)\n", "import pandas as pd\n", "from bokeh.models.widgets import Button, RadioButtonGroup, Select\n", "file_read = file.read()\n", "list_name += '.lst'\n", "list = os.path.dirname(os.getcwd()) + '/' + sql.get_setting('lists_path'\n ) + '/' + form.getvalue('group') + '/' + form.getvalue('color'\n ) + '/' + form.getvalue('bwlists_save')\n", "if form.getvalue('get_lists'):\n", "sys.exit()\n", "funct.ssh_command(master, ['sudo chmod +x ' + tmp_config_path + script, \n tmp_config_path + script + ' MASTER ' + interface + ' ' + vrrpip])\n", "sys.exit()\n", "funct.ssh_command(master, ['sudo chmod +x ' + tmp_config_path + script, \n tmp_config_path + script + ' MASTER ' + interface + ' ' + vrrpip + ' ' +\n kp])\n", "template = template.render(table_stat=sql.select_table_metrics(user_id.value))\n", "import http.cookies\n", "import pandas as pd\n", "file.close\n", "list = os.path.dirname(os.getcwd()) + '/' + sql.get_setting('lists_path'\n ) + '/' + form.getvalue('group') + '/' + form.getvalue('color'\n ) + '/' + list_name\n", "file.write(form.getvalue('bwlists_content'))\n", "print('<div class=\"alert alert-danger\" style=\"margin:0\">Cat\\'n save ' +\n form.getvalue('color') + ' list. %s </div>' % e)\n", "servers = sql.get_dick_permit()\n", "list = os.path.dirname(os.getcwd()) + '/' + sql.get_setting('lists_path'\n ) + '/' + form.getvalue('group') + '/' + form.getvalue('color')\n", "if form.getvalue('get_ldap_email'):\n", "funct.ssh_command(slave, ['sudo chmod +x ' + tmp_config_path + script, \n tmp_config_path + script + ' BACKUP ' + interface + ' ' + vrrpip])\n", "funct.ssh_command(slave, ['sudo chmod +x ' + tmp_config_path + script, \n tmp_config_path + script + ' BACKUP ' + interface + ' ' + vrrpip + ' ' +\n kp])\n", "print(template)\n", "cookie = http.cookies.SimpleCookie(os.environ.get('HTTP_COOKIE'))\n", "import http.cookies\n", "print(file_read)\n", "open(list, 'a').close()\n", "print('<div class=\"alert alert-danger\" style=\"margin:0\">Cat\\'n create new ' +\n form.getvalue('color') + ' list. %s </div>' % e)\n", "path = sql.get_setting('haproxy_dir') + '/' + form.getvalue('color')\n", "lists = funct.get_files(dir=list, format='lst')\n", "username = form.getvalue('get_ldap_email')\n", "os.system('rm -f %s' % script)\n", "os.system('rm -f %s' % script)\n", "user_id = cookie.get('uuid')\n", "cookie = http.cookies.SimpleCookie(os.environ.get('HTTP_COOKIE'))\n", "print('<div class=\"alert alert-success\" style=\"margin:0\">' + form.getvalue(\n 'color') + ' list was created</div>')\n", "for server in servers:\n", "for list in lists:\n", "import ldap\n", "sql.update_server_master(master, slave)\n", "servers = sql.select_servers_metrics(user_id.value)\n", "user_id = cookie.get('uuid')\n", "funct.ssh_command(server[2], ['sudo mkdir ' + path])\n", "print(list)\n", "server = sql.get_setting('ldap_server')\n", "servers = sorted(servers)\n", "servers = sql.select_waf_servers_metrics(user_id.value)\n", "error = funct.upload(server[2], path + '/' + form.getvalue('bwlists_save'),\n list, dir='fullpath')\n", "port = sql.get_setting('ldap_port')\n", "p = {}\n", "servers = sorted(servers)\n", "if error:\n", "user = sql.get_setting('ldap_user')\n", "for serv in servers:\n", "p = {}\n", "print('<div class=\"alert alert-danger\">Upload fail: %s</div>' % error)\n", "print('<div class=\"alert alert-success\" style=\"margin:10px\">Edited ' + form\n .getvalue('color') + ' list was uploaded to ' + server[1] + '</div>')\n", "password = sql.get_setting('ldap_password')\n", "serv = serv[0]\n", "plots = []\n", "for serv in servers:\n", "if form.getvalue('bwlists_restart') == 'restart':\n", "ldap_base = sql.get_setting('ldap_base')\n", "p[serv] = {}\n", "for key, value in p.items():\n", "serv = serv[0]\n", "plots = []\n", "funct.ssh_command(server[2], ['sudo ' + sql.get_setting('restart_command')])\n", "domain = sql.get_setting('ldap_domain')\n", "metric = sql.select_metrics(serv)\n", "plots.append(value)\n", "grid = gridplot(plots, ncols=2, plot_width=800, plot_height=250,\n toolbar_location='left', toolbar_options=dict(logo=None))\n", "p[serv] = {}\n", "for key, value in p.items():\n", "ldap_search_field = sql.get_setting('ldap_search_field')\n", "metrics = {}\n", "show(grid)\n", "metric = sql.select_waf_metrics(serv)\n", "plots.append(value)\n", "grid = gridplot(plots, ncols=2, plot_width=800, plot_height=250,\n toolbar_location='left', toolbar_options=dict(logo=None))\n", "l = ldap.initialize('ldap://' + server + ':' + port)\n", "for i in metric:\n", "metrics = {}\n", "show(grid)\n", "l.protocol_version = ldap.VERSION3\n", "l.unbind()\n", "rep_date = str(i[5])\n", "df = pd.DataFrame.from_dict(metrics, orient='index')\n", "for i in metric:\n", "l.set_option(ldap.OPT_REFERRALS, 0)\n", "metrics[rep_date] = {}\n", "df = df.fillna(0)\n", "rep_date = str(i[2])\n", "df = pd.DataFrame.from_dict(metrics, orient='index')\n", "bind = l.simple_bind_s(user, password)\n", "metrics[rep_date]['server'] = str(i[0])\n", "df.index = pd.to_datetime(df.index)\n", "metrics[rep_date] = {}\n", "df = df.fillna(0)\n", "criteria = '(&(objectClass=user)(sAMAccountName=' + username + '))'\n", "metrics[rep_date]['curr_con'] = str(i[1])\n", "df.index.name = 'Date'\n", "metrics[rep_date]['conn'] = str(i[1])\n", "df.index = pd.to_datetime(df.index)\n", "attributes = [ldap_search_field]\n", "metrics[rep_date]['curr_ssl_con'] = str(i[2])\n", "df.sort_index(inplace=True)\n", "df.index.name = 'Date'\n", "result = l.search_s(ldap_base, ldap.SCOPE_SUBTREE, criteria, attributes)\n", "metrics[rep_date]['sess_rate'] = str(i[3])\n", "source = ColumnDataSource(df)\n", "df.sort_index(inplace=True)\n", "results = [entry for dn, entry in result if isinstance(entry, dict)]\n", "metrics[rep_date]['max_sess_rate'] = str(i[4])\n", "output_file('templates/metrics_out.html', mode='inline')\n", "source = ColumnDataSource(df)\n", "print('[\"' + results[0][ldap_search_field][0].decode('utf-8') + '\",\"' +\n domain + '\"]')\n", "print('error: user not found')\n", "x_min = df.index.min() - pd.Timedelta(hours=1)\n", "output_file('templates/metrics_waf_out.html', mode='inline')\n", "x_max = df.index.max() + pd.Timedelta(minutes=1)\n", "x_min = df.index.min() - pd.Timedelta(hours=1)\n", "p[serv] = figure(tools='pan,box_zoom,reset,xwheel_zoom', title=metric[0][0],\n x_axis_type='datetime', y_axis_label='Connections', x_range=(x_max.\n timestamp() * 1000 - 60 * 100000, x_max.timestamp() * 1000))\n", "x_max = df.index.max() + pd.Timedelta(minutes=1)\n", "hover = HoverTool(tooltips=[('Connections', '@curr_con'), (\n 'SSL connections', '@curr_ssl_con'), ('Sessions rate', '@sess_rate')],\n mode='mouse')\n", "p[serv] = figure(tools='pan,box_zoom,reset,xwheel_zoom', title=metric[0][0],\n x_axis_type='datetime', y_axis_label='Connections', x_range=(x_max.\n timestamp() * 1000 - 60 * 100000, x_max.timestamp() * 1000))\n", "p[serv].ygrid.band_fill_color = '#f3f8fb'\n", "hover = HoverTool(tooltips=[('Connections', '@conn')], mode='mouse')\n", "p[serv].ygrid.band_fill_alpha = 0.9\n", "p[serv].ygrid.band_fill_color = '#f3f8fb'\n", "p[serv].y_range.start = 0\n", "p[serv].ygrid.band_fill_alpha = 0.9\n", "p[serv].y_range.end = int(df['curr_con'].max()) + 150\n", "p[serv].y_range.start = 0\n", "p[serv].add_tools(hover)\n", "p[serv].y_range.end = int(df['conn'].max()) + 150\n", "p[serv].title.text_font_size = '20px'\n", "p[serv].add_tools(hover)\n", "p[serv].line('Date', 'curr_con', source=source, alpha=0.5, color='#5cb85c',\n line_width=2, legend='Conn')\n", "p[serv].title.text_font_size = '20px'\n", "p[serv].line('Date', 'curr_ssl_con', source=source, alpha=0.5, color=\n '#5d9ceb', line_width=2, legend='SSL con')\n", "p[serv].line('Date', 'conn', source=source, alpha=0.5, color='#5cb85c',\n line_width=2, legend='Conn')\n", "p[serv].line('Date', 'sess_rate', source=source, alpha=0.5, color='#33414e',\n line_width=2, legend='Sessions')\n", "p[serv].legend.orientation = 'horizontal'\n", "p[serv].legend.orientation = 'horizontal'\n", "p[serv].legend.location = 'top_left'\n", "p[serv].legend.location = 'top_left'\n", "p[serv].legend.padding = 5\n", "p[serv].legend.padding = 5\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "Import'", "Import'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Condition", "For", "Expr'", "Condition", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "For", "Expr'", "Assign'", "Expr'", "Condition", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Expr'", "Import'", "Condition", "ImportFrom'", "Import'", "Condition", "Assign'", "ImportFrom'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Import'", "Condition", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "ImportFrom'", "ImportFrom'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "ImportFrom'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Import'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "ImportFrom'", "ImportFrom'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "ImportFrom'", "ImportFrom'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "ImportFrom'", "ImportFrom'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "ImportFrom'", "ImportFrom'", "Expr'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "ImportFrom'", "ImportFrom'", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Import'", "ImportFrom'", "Assign'", "AugAssign'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Import'", "Import'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Assign'", "Import'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "For", "For", "Import'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "For", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "For", "Condition", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "For", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "For", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_2(self):...\n", "VAR_1 = self.client.get(reverse('core-views-index'))\n", "self.assertRedirects(VAR_1, reverse('tcms-login'), target_status_code=\n HTTPStatus.OK)\n" ]
[ "def test_when_not_logged_in_index_page_redirects_to_login(self):...\n", "response = self.client.get(reverse('core-views-index'))\n", "self.assertRedirects(response, reverse('tcms-login'), target_status_code=\n HTTPStatus.OK)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "@login_required...\n", "\"\"\"docstring\"\"\"\n", "return render_to_response('student_account/finish_auth.html', {\n 'disable_courseware_js': True, 'disable_footer': True})\n" ]
[ "@login_required...\n", "\"\"\"docstring\"\"\"\n", "return render_to_response('student_account/finish_auth.html', {\n 'disable_courseware_js': True, 'disable_footer': True})\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def __call__(self, VAR_20):...\n", "" ]
[ "def __call__(self, urls):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_14(self, VAR_20, VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_21 == VAR_20 + '/':\n", "VAR_29 = VAR_20.split('/')[-1] + '/'\n", "if VAR_20 == VAR_21 + self.index_file:\n", "if self.max_age is not None:\n", "VAR_29 = './'\n", "VAR_19 = {'Cache-Control': 'max-age={0}, public'.format(self.max_age)}\n", "VAR_19 = {}\n", "return Redirect(VAR_29, VAR_19=headers)\n" ]
[ "def redirect(self, from_url, to_url):...\n", "\"\"\"docstring\"\"\"\n", "if to_url == from_url + '/':\n", "relative_url = from_url.split('/')[-1] + '/'\n", "if from_url == to_url + self.index_file:\n", "if self.max_age is not None:\n", "relative_url = './'\n", "headers = {'Cache-Control': 'max-age={0}, public'.format(self.max_age)}\n", "headers = {}\n", "return Redirect(relative_url, headers=headers)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_0():...\n", "\"\"\"docstring\"\"\"\n", "VAR_0 = subprocess.run(['/opt/tljh/user/bin/jupyter-serverextension',\n 'list', '--sys-prefix'], stderr=subprocess.PIPE)\n", "VAR_1 = ['jupyterlab 0.35.3', 'nbgitpuller 0.6.1',\n 'nteract_on_jupyter 1.9.12', 'nbresuse ']\n", "for e in VAR_1:\n", "assert '{} \\x1b[32mOK\\x1b[0m'.format(e) in VAR_0.stderr.decode()\n" ]
[ "def test_serverextensions():...\n", "\"\"\"docstring\"\"\"\n", "proc = subprocess.run(['/opt/tljh/user/bin/jupyter-serverextension', 'list',\n '--sys-prefix'], stderr=subprocess.PIPE)\n", "extensions = ['jupyterlab 0.35.3', 'nbgitpuller 0.6.1',\n 'nteract_on_jupyter 1.9.12', 'nbresuse ']\n", "for e in extensions:\n", "assert '{} \\x1b[32mOK\\x1b[0m'.format(e) in proc.stderr.decode()\n" ]
[ 0, 0, 0, 6, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "For", "Assert'" ]
[ "def FUNC_3(self):...\n", "VAR_15 = self._server_popen.poll()\n", "return VAR_15 is None\n" ]
[ "def _IsServerAlive(self):...\n", "returncode = self._server_popen.poll()\n", "return returncode is None\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_6(self, VAR_38):...\n", "VAR_38 = CLASS_17.run(self, VAR_38)\n", "if VAR_38 and self.only_whitespace.match(VAR_38):\n", "VAR_101.errors.add(errors.NO_TITLE)\n", "return VAR_38\n" ]
[ "def run(self, title):...\n", "title = VLength.run(self, title)\n", "if title and self.only_whitespace.match(title):\n", "c.errors.add(errors.NO_TITLE)\n", "return title\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_2(self, VAR_21, VAR_22):...\n", "\"\"\"docstring\"\"\"\n", "VAR_55 = VAR_21.rstrip('/').split('/')\n", "if len(VAR_55[0]):\n", "VAR_22 = [x for x in VAR_22.split('/') if len(x) and x is not None]\n", "VAR_22, VAR_55 = [], VAR_55[1:]\n", "VAR_21 = VAR_21[1:]\n", "VAR_56 = []\n", "def FUNC_33(VAR_57, VAR_22):...\n", "if not len(VAR_57):\n", "VAR_56.append('/%s' % ('/'.join(VAR_22),))\n", "if VAR_57[0] == '.':\n", "FUNC_33(VAR_55, VAR_22)\n", "FUNC_33(VAR_57[1:], VAR_22)\n", "if VAR_57[0] == '..':\n", "return VAR_56\n", "FUNC_33(VAR_57[1:], VAR_22[:-1])\n", "VAR_65 = [x[VAR_1] for x in self.get_path('/'.join(VAR_22))]\n", "VAR_74 = [x for x in VAR_65 if fnmatch.fnmatchcase(x, VAR_57[0])]\n", "for match in VAR_74:\n", "FUNC_33(VAR_57[1:], VAR_22 + [match])\n" ]
[ "def resolve_path_wc(self, path, cwd):...\n", "\"\"\"docstring\"\"\"\n", "pieces = path.rstrip('/').split('/')\n", "if len(pieces[0]):\n", "cwd = [x for x in cwd.split('/') if len(x) and x is not None]\n", "cwd, pieces = [], pieces[1:]\n", "path = path[1:]\n", "found = []\n", "def foo(p, cwd):...\n", "if not len(p):\n", "found.append('/%s' % ('/'.join(cwd),))\n", "if p[0] == '.':\n", "foo(pieces, cwd)\n", "foo(p[1:], cwd)\n", "if p[0] == '..':\n", "return found\n", "foo(p[1:], cwd[:-1])\n", "names = [x[A_NAME] for x in self.get_path('/'.join(cwd))]\n", "matches = [x for x in names if fnmatch.fnmatchcase(x, p[0])]\n", "for match in matches:\n", "foo(p[1:], cwd + [match])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Return'", "Expr'", "Assign'", "Assign'", "For", "Expr'" ]
[ "def __init__(self, VAR_7, VAR_8=False):...\n", "super(CLASS_0, self).__init__()\n", "self._sock = VAR_7\n", "self._ownsock = VAR_8\n" ]
[ "def __init__(self, sock, ownsock=False):...\n", "super(DebugSessionConnection, self).__init__()\n", "self._sock = sock\n", "self._ownsock = ownsock\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'" ]
[ "def FUNC_3(self) ->bool:...\n", "\"\"\"docstring\"\"\"\n", "return True\n" ]
[ "def check_xsrf_cookie(self) ->bool:...\n", "\"\"\"docstring\"\"\"\n", "return True\n" ]
[ 0, 0, 5 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "import subprocess\n", "def __init__(self, VAR_0, VAR_1, VAR_2, VAR_3):...\n", "self.connection = VAR_0\n", "self.logger = VAR_2\n", "self.verb = VAR_3\n", "self.path = VAR_1.pop()\n", "self.pipe_command = VAR_1.pop() if VAR_1 else None\n", "def __del__(self):...\n", "self.connection.close()\n", "def FUNC_0(self, VAR_4={}):...\n", "self.connection.request(self.verb, self.path, VAR_4=headers)\n", "return self.connection.getresponse()\n" ]
[ "import subprocess\n", "def __init__(self, connection, args, logger, verb):...\n", "self.connection = connection\n", "self.logger = logger\n", "self.verb = verb\n", "self.path = args.pop()\n", "self.pipe_command = args.pop() if args else None\n", "def __del__(self):...\n", "self.connection.close()\n", "def run(self, headers={}):...\n", "self.connection.request(self.verb, self.path, headers=headers)\n", "return self.connection.getresponse()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "Return'" ]
[ "@VAR_1.route('/demo3', methods=['GET', 'POST'])...\n", "if request.method == 'GET':\n", "return render_template('demo3.html', faculty_status=faculty_status,\n fields_of_study=fields_of_study, departments=departments, careerareas=\n careerareas, ipedssectornames=ipedssectornames, occupations=occupations)\n", "print(request.form)\n", "VAR_21 = request.form.getlist('jobtype')\n", "VAR_22 = request.form.getlist('staff')\n", "VAR_23 = request.form.getlist('fac')\n", "VAR_14 = request.form.getlist('year')\n", "VAR_24 = request.form.getlist('fos')\n", "VAR_25 = request.form.getlist('dept')\n", "VAR_26 = request.form.getlist('diversityandinclusion')\n", "VAR_27 = request.form.getlist('isresearch1institution')\n", "VAR_28 = request.form.getlist('careerarea')\n", "VAR_15 = request.form.getlist('ipedssectornames')\n", "VAR_29 = request.form.getlist('occupations')\n", "VAR_30 = request.form.get('minimumedurequirements')\n", "VAR_31 = request.form.get('maximumedurequirements')\n", "VAR_32 = request.form.get('minimumexperiencerequirements')\n", "print('min ed = ' + VAR_30)\n", "VAR_8 = (\n 'SELECT count(*) from hej,maintable where (hej.jobid=maintable.jobid) and '\n )\n", "VAR_8 += FUNC_10(VAR_21) + ' and '\n", "if VAR_22 != []:\n", "VAR_8 += ' (faculty=0 and postdoctoral=0) and '\n", "VAR_8 += FUNC_10(VAR_24) + ' and '\n", "VAR_8 += FUNC_11(VAR_14) + ' and '\n", "VAR_8 += FUNC_10(VAR_25) + ' and '\n", "VAR_8 += FUNC_10(VAR_23) + ' and '\n", "VAR_8 += FUNC_10(VAR_26 + VAR_27) + ' and '\n", "VAR_8 += FUNC_12(VAR_28) + ' and '\n", "VAR_8 += FUNC_13('ipedssectorname', VAR_15) + ' and '\n", "VAR_8 += FUNC_13('occupation', VAR_29) + ' and '\n", "VAR_8 += 'minimumedurequirements >= ' + VAR_30 + ' and '\n", "VAR_8 += 'maximumedurequirements <= ' + VAR_31 + ' and '\n", "VAR_8 += 'minimumexperiencerequirements >= ' + VAR_32\n", "VAR_8 += ' group by hej.year'\n", "print(VAR_8)\n", "VAR_9 = FUNC_15(VAR_8)\n", "print(VAR_9)\n", "if VAR_9 == []:\n", "print('no results')\n", "VAR_18 = [VAR_3[0] for VAR_3 in VAR_9]\n", "return render_template('noResults.html', VAR_8=query)\n", "VAR_19 = [FUNC_8(VAR_3) for VAR_3 in VAR_18]\n", "VAR_20 = []\n", "for i in range(0, len(VAR_14)):\n", "VAR_20 += [FUNC_9(VAR_14[i], VAR_18[i])]\n", "print(VAR_9)\n", "print(VAR_18)\n", "print(VAR_19)\n", "print(VAR_20)\n", "VAR_16 = [int(VAR_4) for VAR_4 in VAR_14]\n", "return render_template('demo3b.html', VAR_8=query, VAR_14=years, VAR_18=z1)\n" ]
[ "@app.route('/demo3', methods=['GET', 'POST'])...\n", "if request.method == 'GET':\n", "return render_template('demo3.html', faculty_status=faculty_status,\n fields_of_study=fields_of_study, departments=departments, careerareas=\n careerareas, ipedssectornames=ipedssectornames, occupations=occupations)\n", "print(request.form)\n", "jobtype = request.form.getlist('jobtype')\n", "staff = request.form.getlist('staff')\n", "fac = request.form.getlist('fac')\n", "year = request.form.getlist('year')\n", "fos = request.form.getlist('fos')\n", "dept = request.form.getlist('dept')\n", "divinc = request.form.getlist('diversityandinclusion')\n", "rsh1 = request.form.getlist('isresearch1institution')\n", "careerarea = request.form.getlist('careerarea')\n", "ipeds = request.form.getlist('ipedssectornames')\n", "occs = request.form.getlist('occupations')\n", "min_ed = request.form.get('minimumedurequirements')\n", "max_ed = request.form.get('maximumedurequirements')\n", "min_exp = request.form.get('minimumexperiencerequirements')\n", "print('min ed = ' + min_ed)\n", "query = (\n 'SELECT count(*) from hej,maintable where (hej.jobid=maintable.jobid) and '\n )\n", "query += makeBoolean(jobtype) + ' and '\n", "if staff != []:\n", "query += ' (faculty=0 and postdoctoral=0) and '\n", "query += makeBoolean(fos) + ' and '\n", "query += makeYears(year) + ' and '\n", "query += makeBoolean(dept) + ' and '\n", "query += makeBoolean(fac) + ' and '\n", "query += makeBoolean(divinc + rsh1) + ' and '\n", "query += makeCareerAreas(careerarea) + ' and '\n", "query += makeStrings('ipedssectorname', ipeds) + ' and '\n", "query += makeStrings('occupation', occs) + ' and '\n", "query += 'minimumedurequirements >= ' + min_ed + ' and '\n", "query += 'maximumedurequirements <= ' + max_ed + ' and '\n", "query += 'minimumexperiencerequirements >= ' + min_exp\n", "query += ' group by hej.year'\n", "print(query)\n", "z = queryAll(query)\n", "print(z)\n", "if z == []:\n", "print('no results')\n", "z1 = [x[0] for x in z]\n", "return render_template('noResults.html', query=query)\n", "z2 = [makeObj(x) for x in z1]\n", "vals = []\n", "for i in range(0, len(year)):\n", "vals += [makeObj2(year[i], z1[i])]\n", "print(z)\n", "print(z1)\n", "print(z2)\n", "print(vals)\n", "years = [int(y) for y in year]\n", "return render_template('demo3b.html', query=query, year=years, z1=z1)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "AugAssign'", "Condition", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Return'", "Assign'", "Assign'", "For", "AugAssign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Return'" ]
[ "@app.route('/api/uploads/<sid>/download')...\n", "if not utils.sid_is_valid(VAR_0):\n", "abort(400)\n", "VAR_4 = os.path.join(app.config['UPLOAD_FOLDER'], VAR_0)\n", "if os.path.isfile(os.path.join(VAR_4, app.config['RESULTS_ZIP'])):\n", "return send_from_directory(directory=path, filename=app.config['RESULTS_ZIP'])\n", "abort(404)\n" ]
[ "@app.route('/api/uploads/<sid>/download')...\n", "if not utils.sid_is_valid(sid):\n", "abort(400)\n", "path = os.path.join(app.config['UPLOAD_FOLDER'], sid)\n", "if os.path.isfile(os.path.join(path, app.config['RESULTS_ZIP'])):\n", "return send_from_directory(directory=path, filename=app.config['RESULTS_ZIP'])\n", "abort(404)\n" ]
[ 0, 2, 0, 0, 2, 0, 0 ]
[ "Condition", "Condition", "Expr'", "Assign'", "Condition", "Return'", "Expr'" ]
[ "def FUNC_3(VAR_5, VAR_6=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_43 = None\n", "VAR_44 = None\n", "VAR_45 = '%Y-%m-%d %H:%M:%S.%f'\n", "if VAR_6:\n", "VAR_45 = ('%Y-%m-%d %H:%M:%S.%f' if VAR_6.fieldtype == 'Datetime' else\n '%Y-%m-%d')\n", "if VAR_5 and isinstance(VAR_5, (list, tuple)):\n", "if len(VAR_5) >= 1:\n", "if not VAR_6 or VAR_6 and VAR_6.fieldtype == 'Datetime':\n", "VAR_43 = VAR_5[0]\n", "if len(VAR_5) >= 2:\n", "VAR_44 = add_to_date(VAR_44, days=1)\n", "VAR_46 = \"'%s' AND '%s'\" % (get_datetime(VAR_43).strftime(VAR_45),\n get_datetime(VAR_44).strftime(VAR_45))\n", "VAR_44 = VAR_5[1]\n", "return VAR_46\n" ]
[ "def get_between_date_filter(value, df=None):...\n", "\"\"\"docstring\"\"\"\n", "from_date = None\n", "to_date = None\n", "date_format = '%Y-%m-%d %H:%M:%S.%f'\n", "if df:\n", "date_format = ('%Y-%m-%d %H:%M:%S.%f' if df.fieldtype == 'Datetime' else\n '%Y-%m-%d')\n", "if value and isinstance(value, (list, tuple)):\n", "if len(value) >= 1:\n", "if not df or df and df.fieldtype == 'Datetime':\n", "from_date = value[0]\n", "if len(value) >= 2:\n", "to_date = add_to_date(to_date, days=1)\n", "data = \"'%s' AND '%s'\" % (get_datetime(from_date).strftime(date_format),\n get_datetime(to_date).strftime(date_format))\n", "to_date = value[1]\n", "return data\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_2(self):...\n", "self._check_key(VAR_0)\n" ]
[ "def test_rsa_key(self):...\n", "self._check_key(RSA_PUBKEY)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_28(VAR_25, VAR_26, VAR_27):...\n", "\"\"\"docstring\"\"\"\n", "VAR_54 = VAR_25.strftime(VAR_27)\n", "VAR_27 = VAR_18(VAR_54, **tags.__dict__)\n", "return VAR_27\n" ]
[ "def generate_date_mapping(date_value, tags, path_string):...\n", "\"\"\"docstring\"\"\"\n", "time_string = date_value.strftime(path_string)\n", "path_string = tpl(time_string, **tags.__dict__)\n", "return path_string\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_1(self):...\n", "return 'load page for task %s (%s)' % (self.task_id, self.url)\n" ]
[ "def describe(self):...\n", "return 'load page for task %s (%s)' % (self.task_id, self.url)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@integration_synonym_api...\n", "FUNC_2(VAR_2)\n", "FUNC_3(VAR_2, 'AYAAN', VAR_7='1')\n", "FUNC_5(VAR_4, VAR_5, VAR_11='AYAN', VAR_10=[{'name': '----AYAN'}, {'name':\n 'AYAAN'}])\n" ]
[ "@integration_synonym_api...\n", "clean_database(solr)\n", "seed_database_with(solr, 'AYAAN', id='1')\n", "verify_results(client, jwt, query='AYAN', expected=[{'name': '----AYAN'}, {\n 'name': 'AYAAN'}])\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_1(self):...\n", "return dict(VAR_2=self.idleTimeout, VAR_3=self.timeout, VAR_4=self.insecure)\n" ]
[ "def toDict(self):...\n", "return dict(idleTimeout=self.idleTimeout, timeout=self.timeout, insecure=\n self.insecure)\n" ]
[ 0, 2 ]
[ "FunctionDef'", "Return'" ]
[ "def __len__(self):...\n", "return len(self._data)\n" ]
[ "def __len__(self):...\n", "return len(self._data)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self.config.get(self.section, 'pysaml2_config')\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self.config.get(self.section, 'pysaml2_config')\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def __str__(self):...\n", "return 'Error executing adb cmd \"%s\". ret: %d, stdout: %s, stderr: %s' % (self\n .cmd, self.ret_code, self.stdout, self.stderr)\n" ]
[ "def __str__(self):...\n", "return 'Error executing adb cmd \"%s\". ret: %d, stdout: %s, stderr: %s' % (self\n .cmd, self.ret_code, self.stdout, self.stderr)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "\"\"\"string\"\"\"\n", "import MySQLdb\n", "import dbconn2\n", "VAR_0 = 'svoigt'\n", "def FUNC_0(VAR_1):...\n", "VAR_6 = FUNC_3(VAR_1)\n", "VAR_7 = VAR_6.cursor(MySQLdb.cursors.DictCursor)\n", "VAR_8 = (\n \"SELECT * FROM questions WHERE status='not-started' OR status='in-progress' ORDER BY ts DESC;\"\n )\n", "VAR_7.execute(VAR_8)\n", "VAR_9 = []\n", "while True:\n", "VAR_10 = VAR_7.fetchone()\n", "if VAR_10 == None:\n", "VAR_9.append(\n \"<input type='submit' name=questionSubmit value='Answer Selected Question'>\"\n )\n", "VAR_9.append('string'.format(VAR_2=row['id'], question=row['question'],\n status=row['status'], ts=row['ts']))\n", "return '\\n'.join(VAR_9)\n", "if VAR_10['status'] == 'in-progress':\n", "VAR_9.append('<p>In-Progress Answer: {curr_answer}'.format(curr_answer=row[\n 'answer']))\n", "VAR_9.append('</div>')\n" ]
[ "\"\"\"\nAuthor: Samantha Voigt\nLast Modified: 4/19/16\nanswerQuestions.py\n\nTODO: Write a description of the file\n\nTODO: sort by timestamp\n\n\"\"\"\n", "import MySQLdb\n", "import dbconn2\n", "USER = 'svoigt'\n", "def makeQuestionSelect(database):...\n", "conn = dbConnect(database)\n", "curs = conn.cursor(MySQLdb.cursors.DictCursor)\n", "statement = (\n \"SELECT * FROM questions WHERE status='not-started' OR status='in-progress' ORDER BY ts DESC;\"\n )\n", "curs.execute(statement)\n", "lines = []\n", "while True:\n", "row = curs.fetchone()\n", "if row == None:\n", "lines.append(\n \"<input type='submit' name=questionSubmit value='Answer Selected Question'>\"\n )\n", "lines.append(\n \"\"\"<div style='border:2px solid black;'><input type='radio' name='q_selection' value={id}> Question: {question}\n<p>Status: {status}\n<p>Time submitted: {ts}\"\"\"\n .format(id=row['id'], question=row['question'], status=row['status'],\n ts=row['ts']))\n", "return '\\n'.join(lines)\n", "if row['status'] == 'in-progress':\n", "lines.append('<p>In-Progress Answer: {curr_answer}'.format(curr_answer=row[\n 'answer']))\n", "lines.append('</div>')\n" ]
[ 4, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "Import'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Return'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_22(VAR_18, VAR_31, VAR_30=60):...\n", "VAR_50 = re.compile('Compiling\\\\.\\\\.\\\\.|Evaluating\\\\.\\\\.\\\\.')\n", "VAR_51 = re.compile('Compilation failed|Evaluated')\n", "VAR_34 = FUNC_0()\n", "VAR_52 = 0.1\n", "while VAR_30 > 0:\n", "VAR_30 -= VAR_52\n", "VAR_49 = AWSUserTestViewRequest(VAR_34, VAR_31, base_url=AWS_BASE_URL)\n", "VAR_49.execute()\n", "VAR_63 = VAR_49.get_user_test_info()\n", "VAR_64 = VAR_63['status']\n", "if VAR_51.search(VAR_64):\n", "return VAR_63\n", "if VAR_50.search(VAR_64):\n", "time.sleep(VAR_52)\n" ]
[ "def get_user_test_result(contest_id, user_test_id, timeout=60):...\n", "WAITING_STATUSES = re.compile('Compiling\\\\.\\\\.\\\\.|Evaluating\\\\.\\\\.\\\\.')\n", "COMPLETED_STATUS = re.compile('Compilation failed|Evaluated')\n", "browser = get_aws_browser()\n", "sleep_interval = 0.1\n", "while timeout > 0:\n", "timeout -= sleep_interval\n", "sr = AWSUserTestViewRequest(browser, user_test_id, base_url=AWS_BASE_URL)\n", "sr.execute()\n", "result = sr.get_user_test_info()\n", "status = result['status']\n", "if COMPLETED_STATUS.search(status):\n", "return result\n", "if WAITING_STATUSES.search(status):\n", "time.sleep(sleep_interval)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "AugAssign'", "Assign'", "Expr'", "Assign'", "Assign'", "Condition", "Return'", "Condition", "Expr'" ]
[ "def FUNC_0(VAR_2):...\n", "if isinstance(VAR_2, type) and issubclass(VAR_2, CLASS_2):\n", "return VAR_2._meta.resource_name, VAR_2._meta.type_field\n", "return VAR_2, VAR_0\n" ]
[ "def resolve_resource_type(resource):...\n", "if isinstance(resource, type) and issubclass(resource, Resource):\n", "return resource._meta.resource_name, resource._meta.type_field\n", "return resource, DEFAULT_TYPE_FIELD\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_7():...\n", "if len(sys.argv) != 2:\n", "print('Give one app package path.')\n", "VAR_17 = sys.argv[1]\n", "exit()\n", "FUNC_0(VAR_17)\n", "CLASS_1(VAR_17).analyze()\n", "sys.exit(VAR_1)\n" ]
[ "def main():...\n", "if len(sys.argv) != 2:\n", "print('Give one app package path.')\n", "app_path = sys.argv[1]\n", "exit()\n", "header(app_path)\n", "App(app_path).analyze()\n", "sys.exit(return_code)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "from __future__ import unicode_literals\n", "import frappe\n", "from frappe import _\n", "from erpnext.hr.doctype.leave_application.leave_application import get_leave_allocation_records, get_leave_balance_on, get_approved_leaves_for_period\n", "def FUNC_0(VAR_0=None):...\n", "VAR_1 = frappe.db.sql_list('select name from `tabLeave Type` order by name asc'\n )\n", "VAR_3 = FUNC_1(VAR_1)\n", "VAR_4 = FUNC_2(VAR_0, VAR_1)\n", "return VAR_3, VAR_4\n" ]
[ "from __future__ import unicode_literals\n", "import frappe\n", "from frappe import _\n", "from erpnext.hr.doctype.leave_application.leave_application import get_leave_allocation_records, get_leave_balance_on, get_approved_leaves_for_period\n", "def execute(filters=None):...\n", "leave_types = frappe.db.sql_list(\n 'select name from `tabLeave Type` order by name asc')\n", "columns = get_columns(leave_types)\n", "data = get_data(filters, leave_types)\n", "return columns, data\n" ]
[ 0, 0, 0, 4, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_15(VAR_10, VAR_8, VAR_12=2):...\n", "" ]
[ "def get_html_float_to_str(src, name, precision=2):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_15(self, VAR_16, VAR_18):...\n", "\"\"\"docstring\"\"\"\n", "VAR_25 = self._eql_execute('volume', 'select', VAR_18['volume_name'],\n 'snapshot', 'select', VAR_18['name'], 'clone', VAR_16['name'])\n", "VAR_0.error(_('Failed to create volume from snapshot %s'), VAR_18['name'])\n", "return self._get_volume_data(VAR_25)\n" ]
[ "def create_volume_from_snapshot(self, volume, snapshot):...\n", "\"\"\"docstring\"\"\"\n", "out = self._eql_execute('volume', 'select', snapshot['volume_name'],\n 'snapshot', 'select', snapshot['name'], 'clone', volume['name'])\n", "LOG.error(_('Failed to create volume from snapshot %s'), snapshot['name'])\n", "return self._get_volume_data(out)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_7(self):...\n", "VAR_11 = []\n", "for VAR_1, VAR_2 in self.turningNodes:\n", "VAR_17 = 0\n", "return VAR_11\n", "for turn in self.stateMap[VAR_1][VAR_2].getTurning():\n", "if turn != -1:\n", "VAR_11.append([(VAR_1, VAR_2), turn[0], turn[1]])\n", "VAR_17 += 1\n" ]
[ "def getNodeConnectionCoords(self):...\n", "coords = []\n", "for x, y in self.turningNodes:\n", "z = 0\n", "return coords\n", "for turn in self.stateMap[x][y].getTurning():\n", "if turn != -1:\n", "coords.append([(x, y), turn[0], turn[1]])\n", "z += 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Assign'", "Return'", "For", "Condition", "Expr'", "AugAssign'" ]
[ "def FUNC_5(self):...\n", "VAR_1 = self.c.get('/find/?q=insecticide')\n", "VAR_2 = VAR_1.content.count(b'name=\"brand_name\"')\n", "self.assertTrue(VAR_2 > 10,\n 'There should be ~143 product returns for this search term')\n" ]
[ "def test_product_facet_returns(self):...\n", "response = self.c.get('/find/?q=insecticide')\n", "brands = response.content.count(b'name=\"brand_name\"')\n", "self.assertTrue(brands > 10,\n 'There should be ~143 product returns for this search term')\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "@integration_synonym_api...\n", "FUNC_2(VAR_2)\n", "FUNC_3(VAR_2, 'KRYSTAL', VAR_7='1')\n", "FUNC_5(VAR_4, VAR_5, VAR_11='CRISTAL', VAR_10=[{'name': '----CRISTAL'}, {\n 'name': 'KRYSTAL'}])\n" ]
[ "@integration_synonym_api...\n", "clean_database(solr)\n", "seed_database_with(solr, 'KRYSTAL', id='1')\n", "verify_results(client, jwt, query='CRISTAL', expected=[{'name':\n '----CRISTAL'}, {'name': 'KRYSTAL'}])\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_34(self, VAR_14):...\n", "return self.list_properties[VAR_14].mapper.class_\n" ]
[ "def get_related_model(self, col_name):...\n", "return self.list_properties[col_name].mapper.class_\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "async def FUNC_2(self, VAR_5):...\n", "if isinstance(VAR_5, ExtractLinksEvent):\n", "VAR_37 = iter(VAR_5.links)\n", "VAR_38 = 100\n", "while True:\n", "VAR_48 = list(islice(VAR_37, 0, VAR_38))\n", "if not VAR_48:\n", "self.logger.info('extracted links', context=type(item).__name__, VAR_52=\n '8ee5e9c9-1130-4c5c-88ff-718508546e0c', VAR_57=limitlinks)\n" ]
[ "async def push(self, item):...\n", "if isinstance(item, ExtractLinksEvent):\n", "it = iter(item.links)\n", "limit = 100\n", "while True:\n", "limitlinks = list(islice(it, 0, limit))\n", "if not limitlinks:\n", "self.logger.info('extracted links', context=type(item).__name__, uuid=\n '8ee5e9c9-1130-4c5c-88ff-718508546e0c', links=limitlinks)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_1(VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "VAR_3 = sqlite3.connect(VAR_0)\n", "VAR_1 = 'select * from home_user WHERE id={};'.format(VAR_2)\n", "print('sql', VAR_1)\n", "VAR_4 = VAR_3.cursor()\n", "VAR_4.execute(VAR_1)\n", "VAR_5 = VAR_4.fetchall()\n", "return VAR_5\n" ]
[ "def get_one_user(user_id):...\n", "\"\"\"docstring\"\"\"\n", "conn = sqlite3.connect(DB_FILE)\n", "sql = 'select * from home_user WHERE id={};'.format(user_id)\n", "print('sql', sql)\n", "cursor = conn.cursor()\n", "cursor.execute(sql)\n", "res = cursor.fetchall()\n", "return res\n" ]
[ 0, 0, 0, 0, 4, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "async def FUNC_2(self, VAR_1, VAR_2):...\n", "VAR_6 = self.get_all_channels()\n", "VAR_7 = [x for x in VAR_6 if x.name == VAR_2][0]\n", "await VAR_7.send(VAR_1)\n" ]
[ "async def send_channel_message(self, message, channel_name):...\n", "channels = self.get_all_channels()\n", "channel = [x for x in channels if x.name == channel_name][0]\n", "await channel.send(message)\n" ]
[ 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "@query_cached...\n", "VAR_36 = [VAR_26]\n", "for entry in lore.io.bucket.objects.filter(Prefix=os.path.join(self.\n", "VAR_39 = tempfile.NamedTemporaryFile()\n", "return VAR_36\n", "lore.io.bucket.download_file(entry.key, VAR_39.name)\n", "VAR_36 += list(csv.reader(gz, delimiter='|', quotechar='\"'))\n" ]
[ "@query_cached...\n", "result = [columns]\n", "for entry in lore.io.bucket.objects.filter(Prefix=os.path.join(self.\n", "temp = tempfile.NamedTemporaryFile()\n", "return result\n", "lore.io.bucket.download_file(entry.key, temp.name)\n", "result += list(csv.reader(gz, delimiter='|', quotechar='\"'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "For", "Assign'", "Return'", "Expr'", "AugAssign'" ]
[ "def FUNC_2(VAR_1: str) ->str:...\n", "\"\"\"docstring\"\"\"\n", "return FUNC_0(f'git -C {VAR_1} reset --hard')\n" ]
[ "def hard_reset(repo_path: str) ->str:...\n", "\"\"\"docstring\"\"\"\n", "return shell(f'git -C {repo_path} reset --hard')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_30(self):...\n", "\"\"\"docstring\"\"\"\n", "self.sos_cmd = self.config['sos_cmd']\n", "self.sos_cmd = self.host.prefix + self.sos_cmd\n", "VAR_43 = self.determine_sos_label()\n", "if VAR_43:\n", "self.sos_cmd = ' %s %s' % (self.sos_cmd, VAR_43)\n", "if self.config['sos_opt_line']:\n", "return True\n", "if self.config['only_plugins']:\n", "VAR_56 = [o for o in self.config['only_plugins'] if self._plugin_exists(o)]\n", "if self.config['skip_plugins']:\n", "if len(VAR_56) != len(self.config['only_plugins']):\n", "VAR_58 = [o for o in self.config['skip_plugins'] if self._check_enabled(o)]\n", "if self.config['enable_plugins']:\n", "VAR_64 = list(set(self.config['only_plugins']) - set(VAR_56))\n", "VAR_57 = self._fmt_sos_opt_list(self.config['only_plugins'])\n", "if len(VAR_58) != len(self.config['skip_plugins']):\n", "VAR_24 = [o for o in self.config['enable_plugins'] if o not in self.config[\n 'skip_plugins'] and self._check_disabled(o) and self._plugin_exists(o)]\n", "if self.config['plugin_options']:\n", "self.log_debug(\n 'Requested plugins %s were requested to be enabled but do not exist' %\n VAR_64)\n", "if VAR_57:\n", "VAR_65 = list(set(self.config['skip_plugins']) - set(VAR_58))\n", "VAR_59 = self._fmt_sos_opt_list(VAR_58)\n", "if len(VAR_24) != len(self.config['enable_plugins']):\n", "VAR_24 = [o for o in self.config['plugin_options'] if self._plugin_exists(o\n .split('.')[0]) and self._plugin_option_exists(o.split('=')[0])]\n", "if self.config['preset']:\n", "self.sos_cmd += ' --only-plugins=%s' % VAR_57\n", "return True\n", "self.log_debug(\n 'Requested to skip plugins %s, but plugins are already not enabled' %\n VAR_65)\n", "if VAR_59:\n", "VAR_66 = list(set(self.config['enable_plugins']) - set(VAR_24))\n", "VAR_60 = self._fmt_sos_opt_list(VAR_24)\n", "if VAR_24:\n", "if self._preset_exists(self.config['preset']):\n", "self.sos_cmd += ' --skip-plugins=%s' % VAR_59\n", "self.log_debug(\n 'Requested to enable plugins %s, but plugins are already enabled or do not exist'\n % VAR_66)\n", "if VAR_60:\n", "self.sos_cmd += ' -k %s' % ','.join(o for o in VAR_24)\n", "self.sos_cmd += ' --preset=%s' % self.config['preset']\n", "self.log_debug(\n 'Requested to enable preset %s but preset does not exist on node' %\n self.config['preset'])\n", "self.sos_cmd += ' --enable-plugins=%s' % VAR_60\n" ]
[ "def finalize_sos_cmd(self):...\n", "\"\"\"docstring\"\"\"\n", "self.sos_cmd = self.config['sos_cmd']\n", "self.sos_cmd = self.host.prefix + self.sos_cmd\n", "label = self.determine_sos_label()\n", "if label:\n", "self.sos_cmd = ' %s %s' % (self.sos_cmd, label)\n", "if self.config['sos_opt_line']:\n", "return True\n", "if self.config['only_plugins']:\n", "plugs = [o for o in self.config['only_plugins'] if self._plugin_exists(o)]\n", "if self.config['skip_plugins']:\n", "if len(plugs) != len(self.config['only_plugins']):\n", "skip = [o for o in self.config['skip_plugins'] if self._check_enabled(o)]\n", "if self.config['enable_plugins']:\n", "not_only = list(set(self.config['only_plugins']) - set(plugs))\n", "only = self._fmt_sos_opt_list(self.config['only_plugins'])\n", "if len(skip) != len(self.config['skip_plugins']):\n", "opts = [o for o in self.config['enable_plugins'] if o not in self.config[\n 'skip_plugins'] and self._check_disabled(o) and self._plugin_exists(o)]\n", "if self.config['plugin_options']:\n", "self.log_debug(\n 'Requested plugins %s were requested to be enabled but do not exist' %\n not_only)\n", "if only:\n", "not_skip = list(set(self.config['skip_plugins']) - set(skip))\n", "skipln = self._fmt_sos_opt_list(skip)\n", "if len(opts) != len(self.config['enable_plugins']):\n", "opts = [o for o in self.config['plugin_options'] if self._plugin_exists(o.\n split('.')[0]) and self._plugin_option_exists(o.split('=')[0])]\n", "if self.config['preset']:\n", "self.sos_cmd += ' --only-plugins=%s' % only\n", "return True\n", "self.log_debug(\n 'Requested to skip plugins %s, but plugins are already not enabled' %\n not_skip)\n", "if skipln:\n", "not_on = list(set(self.config['enable_plugins']) - set(opts))\n", "enable = self._fmt_sos_opt_list(opts)\n", "if opts:\n", "if self._preset_exists(self.config['preset']):\n", "self.sos_cmd += ' --skip-plugins=%s' % skipln\n", "self.log_debug(\n 'Requested to enable plugins %s, but plugins are already enabled or do not exist'\n % not_on)\n", "if enable:\n", "self.sos_cmd += ' -k %s' % ','.join(o for o in opts)\n", "self.sos_cmd += ' --preset=%s' % self.config['preset']\n", "self.log_debug(\n 'Requested to enable preset %s but preset does not exist on node' %\n self.config['preset'])\n", "self.sos_cmd += ' --enable-plugins=%s' % enable\n" ]
[ 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 2 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Return'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "AugAssign'", "Return'", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "AugAssign'", "Expr'", "Condition", "AugAssign'", "AugAssign'", "Expr'", "AugAssign'" ]
[ "def FUNC_19(self, VAR_20, VAR_17=None, VAR_18=None):...\n", "\"\"\"docstring\"\"\"\n", "self.full_clean(VAR_18)\n", "VAR_38 = registration.get_mapping(self.__class__, VAR_20.__class__)\n", "return VAR_38(self, VAR_17).update(VAR_20, VAR_18)\n" ]
[ "def update_existing(self, dest_obj, context=None, ignore_fields=None):...\n", "\"\"\"docstring\"\"\"\n", "self.full_clean(ignore_fields)\n", "mapping = registration.get_mapping(self.__class__, dest_obj.__class__)\n", "return mapping(self, context).update(dest_obj, ignore_fields)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_12(self, VAR_16):...\n", "\"\"\"docstring\"\"\"\n", "VAR_28 = ['volume', 'create', VAR_16['name'], '%sG' % VAR_16['size']]\n", "VAR_0.error(_('Failed to create volume %s'), VAR_16['name'])\n", "if self.configuration.eqlx_pool != 'default':\n", "VAR_28.append('pool')\n", "if self.configuration.san_thin_provision:\n", "VAR_28.append(self.configuration.eqlx_pool)\n", "VAR_28.append('thin-provision')\n", "VAR_25 = self._eql_execute(*VAR_28)\n", "return self._get_volume_data(VAR_25)\n" ]
[ "def create_volume(self, volume):...\n", "\"\"\"docstring\"\"\"\n", "cmd = ['volume', 'create', volume['name'], '%sG' % volume['size']]\n", "LOG.error(_('Failed to create volume %s'), volume['name'])\n", "if self.configuration.eqlx_pool != 'default':\n", "cmd.append('pool')\n", "if self.configuration.san_thin_provision:\n", "cmd.append(self.configuration.eqlx_pool)\n", "cmd.append('thin-provision')\n", "out = self._eql_execute(*cmd)\n", "return self._get_volume_data(out)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_7(self):...\n", "\"\"\"docstring\"\"\"\n", "return self.__entities\n" ]
[ "def get_all(self):...\n", "\"\"\"docstring\"\"\"\n", "return self.__entities\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_0(VAR_1):...\n", "@wraps(VAR_1)...\n", "VAR_17 = make_response(VAR_1(*VAR_6, **kwargs))\n", "VAR_17.headers['Last-Modified'] = datetime.now()\n", "VAR_17.headers['Cache-Control'\n ] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'\n", "VAR_17.headers['Pragma'] = 'no-cache'\n", "VAR_17.headers['Expires'] = '-1'\n", "return VAR_17\n" ]
[ "def nocache(view):...\n", "@wraps(view)...\n", "response = make_response(view(*args, **kwargs))\n", "response.headers['Last-Modified'] = datetime.now()\n", "response.headers['Cache-Control'\n ] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'\n", "response.headers['Pragma'] = 'no-cache'\n", "response.headers['Expires'] = '-1'\n", "return response\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_19(self, VAR_11):...\n", "\"\"\"docstring\"\"\"\n", "if len(self.iscsi_ips) == 1:\n", "return self.iscsi_ips.keys()[0]\n", "VAR_15 = self._get_active_nsp(VAR_11)\n", "if VAR_15 is None:\n", "VAR_15 = self._get_least_used_nsp(self._get_iscsi_nsps())\n", "return self._get_ip_using_nsp(VAR_15)\n", "if VAR_15 is None:\n", "VAR_40 = _('Least busy iSCSI port not found, using first iSCSI port in list.')\n", "VAR_1.warn(VAR_40)\n", "return self.iscsi_ips.keys()[0]\n" ]
[ "def _get_iscsi_ip(self, hostname):...\n", "\"\"\"docstring\"\"\"\n", "if len(self.iscsi_ips) == 1:\n", "return self.iscsi_ips.keys()[0]\n", "nsp = self._get_active_nsp(hostname)\n", "if nsp is None:\n", "nsp = self._get_least_used_nsp(self._get_iscsi_nsps())\n", "return self._get_ip_using_nsp(nsp)\n", "if nsp is None:\n", "msg = _('Least busy iSCSI port not found, using first iSCSI port in list.')\n", "LOG.warn(msg)\n", "return self.iscsi_ips.keys()[0]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_15(self):...\n", "" ]
[ "def testDownloadFileDownloadError(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_6(self):...\n", "VAR_5 = Mock()\n", "VAR_5.sendmail.side_effect = lambda VAR_68: succeed(VAR_68)\n", "return VAR_5\n" ]
[ "def _create_mail_sender(self):...\n", "mail_sender = Mock()\n", "mail_sender.sendmail.side_effect = lambda mail: succeed(mail)\n", "return mail_sender\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "@utils.synchronized('3par', external=True)...\n", "self.common.client_login()\n", "self.common.create_snapshot(VAR_9)\n", "self.common.client_logout()\n" ]
[ "@utils.synchronized('3par', external=True)...\n", "self.common.client_login()\n", "self.common.create_snapshot(snapshot)\n", "self.common.client_logout()\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_7(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.eng is not None and self.backend == 'Simulator' or self.backend == 'IBMBackend':\n", "for qubit in self.reg:\n", "self.eng.deallocate_qubit(qubit)\n" ]
[ "def _deallocate2(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.eng is not None and self.backend == 'Simulator' or self.backend == 'IBMBackend':\n", "for qubit in self.reg:\n", "self.eng.deallocate_qubit(qubit)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "For", "Expr'" ]
[ "def FUNC_8(VAR_3, VAR_11):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_11 == 'login':\n", "return external_auth_login(VAR_3)\n", "if VAR_11 == 'register':\n", "return external_auth_register(VAR_3)\n" ]
[ "def _external_auth_intercept(request, mode):...\n", "\"\"\"docstring\"\"\"\n", "if mode == 'login':\n", "return external_auth_login(request)\n", "if mode == 'register':\n", "return external_auth_register(request)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Return'" ]
[ "def FUNC_9(self, VAR_0):...\n", "\"\"\"docstring\"\"\"\n", "return None\n" ]
[ "def set_dhcp_hostname(self, hostname):...\n", "\"\"\"docstring\"\"\"\n", "return None\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_35(self, VAR_25):...\n", "\"\"\"docstring\"\"\"\n", "VAR_45 = self.config['tmp_dir'] + '/'\n", "VAR_46 = VAR_45 + VAR_25.split('/')[-1]\n", "if not self.local:\n", "self.log_debug('Failed to retrieve %s: %s' % (VAR_25, VAR_67))\n", "if self.file_exists(VAR_25):\n", "self.log_debug('Moving %s to %s' % (VAR_25, VAR_45))\n", "return False\n", "self.log_debug('Copying remote %s to local %s' % (VAR_25, VAR_45))\n", "self.log_debug(\n 'Attempting to copy remote file %s, but it does not exist on filesystem' %\n VAR_25)\n", "shutil.copy(VAR_25, VAR_46)\n", "self.sftp.get(VAR_25, VAR_46)\n", "return False\n", "return True\n" ]
[ "def retrieve_file(self, path):...\n", "\"\"\"docstring\"\"\"\n", "destdir = self.config['tmp_dir'] + '/'\n", "dest = destdir + path.split('/')[-1]\n", "if not self.local:\n", "self.log_debug('Failed to retrieve %s: %s' % (path, err))\n", "if self.file_exists(path):\n", "self.log_debug('Moving %s to %s' % (path, destdir))\n", "return False\n", "self.log_debug('Copying remote %s to local %s' % (path, destdir))\n", "self.log_debug(\n 'Attempting to copy remote file %s, but it does not exist on filesystem' %\n path)\n", "shutil.copy(path, dest)\n", "self.sftp.get(path, dest)\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Return'", "Expr'", "Expr'", "Expr'", "Expr'", "Return'", "Return'" ]
[ "def FUNC_0(self):...\n", "VAR_7 = []\n", "for parent in self.parent_groups:\n", "VAR_7.append(parent.serialize())\n", "self._hosts = None\n", "VAR_8 = dict(VAR_0=self.name, vars=self.vars.copy(), VAR_7=parent_groups,\n depth=self.depth, VAR_9=self.hosts)\n", "return VAR_8\n" ]
[ "def serialize(self):...\n", "parent_groups = []\n", "for parent in self.parent_groups:\n", "parent_groups.append(parent.serialize())\n", "self._hosts = None\n", "result = dict(name=self.name, vars=self.vars.copy(), parent_groups=\n parent_groups, depth=self.depth, hosts=self.hosts)\n", "return result\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Expr'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_9(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_31 = self.commands()\n", "self.expect(CLASS_1.EOF)\n", "return VAR_31\n" ]
[ "def parse(self):...\n", "\"\"\"docstring\"\"\"\n", "root = self.commands()\n", "self.expect(TokenType.EOF)\n", "return root\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Return'" ]
[ "def __getattr__(VAR_0, VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_7(*VAR_15, **VAR_16):...\n", "\"\"\"docstring\"\"\"\n", "return VAR_0(VAR_1, *VAR_15, **kwargs)\n" ]
[ "def __getattr__(cls, name):...\n", "\"\"\"docstring\"\"\"\n", "def new_object(*args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "return cls(name, *args, **kwargs)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_8(self, VAR_7, VAR_8, VAR_9):...\n", "VAR_20 = 'route add {0} {1} {2}'.format(VAR_7, VAR_9, VAR_8)\n", "return shellutil.run(VAR_20, VAR_10=False)\n" ]
[ "def route_add(self, net, mask, gateway):...\n", "cmd = 'route add {0} {1} {2}'.format(net, gateway, mask)\n", "return shellutil.run(cmd, chk_err=False)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_6(self, VAR_51):...\n", "VAR_81 = VAR_51\n", "VAR_51 = FUNC_3(VAR_51)\n", "if not VAR_51:\n", "return self.error(FUNC_4(VAR_81))\n", "VAR_15 = Account._by_name(VAR_51, True)\n", "return VAR_51\n", "return self.error(errors.USERNAME_TAKEN)\n" ]
[ "def run(self, user_name):...\n", "original_user_name = user_name\n", "user_name = chkuser(user_name)\n", "if not user_name:\n", "return self.error(whyuserbad(original_user_name))\n", "a = Account._by_name(user_name, True)\n", "return user_name\n", "return self.error(errors.USERNAME_TAKEN)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Return'", "Return'" ]
[ "@VAR_0.route('/api/issue', methods=['POST'])...\n", "VAR_10 = FUNC_1()\n", "for VAR_7 in request.get_json()['data']:\n", "return jsonify({'data': [], 'errors': ['failed to create rows in sqlite',\n str(error)]}), 400\n", "return 'Not implemented.', 501\n", "FUNC_4(VAR_10.cursor(), VAR_7)\n" ]
[ "@app.route('/api/issue', methods=['POST'])...\n", "connection = get_database_connection()\n", "for issue in request.get_json()['data']:\n", "return jsonify({'data': [], 'errors': ['failed to create rows in sqlite',\n str(error)]}), 400\n", "return 'Not implemented.', 501\n", "create_issue(connection.cursor(), issue)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "For", "Return'", "Return'", "Expr'" ]
[ "def FUNC_8(self, VAR_7):...\n", "\"\"\"docstring\"\"\"\n", "VAR_45 = self._relationships[VAR_7.entity_attr]\n", "return VAR_45.relatee\n" ]
[ "def _get_relatee(self, attribute):...\n", "\"\"\"docstring\"\"\"\n", "rel = self._relationships[attribute.entity_attr]\n", "return rel.relatee\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_10(self):...\n", "frappe.set_user('[email protected]')\n", "self.assertRaises(frappe.PermissionError, get_filters_cond, 'DocType', dict\n (istable=1), [])\n", "self.assertTrue(get_filters_cond('DocType', dict(istable=1), [],\n ignore_permissions=True))\n", "frappe.set_user('Administrator')\n" ]
[ "def test_ignore_permissions_for_get_filters_cond(self):...\n", "frappe.set_user('[email protected]')\n", "self.assertRaises(frappe.PermissionError, get_filters_cond, 'DocType', dict\n (istable=1), [])\n", "self.assertTrue(get_filters_cond('DocType', dict(istable=1), [],\n ignore_permissions=True))\n", "frappe.set_user('Administrator')\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "\"\"\"string\"\"\"\n", "import requests\n", "import toml\n", "import os\n", "def FUNC_0(VAR_0):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1 = os.path.basename(VAR_0)\n", "if os.path.exists(VAR_1):\n", "return\n", "VAR_15 = requests.get(VAR_0, stream=True)\n", "VAR_15.raise_for_status()\n", "for chunk in VAR_15.iter_content(4096):\n", "fd.write(chunk)\n", "def FUNC_1(VAR_0):...\n", "\"\"\"docstring\"\"\"\n", "VAR_16 = os.path.basename(VAR_0)\n", "print('Fetching %s...' % VAR_16)\n", "FUNC_0(VAR_0 + '.asc')\n", "FUNC_0(VAR_0)\n", "FUNC_0(VAR_0 + '.sha256')\n", "FUNC_0(VAR_0 + '.asc.sha256')\n", "print('Verifying %s...' % VAR_16)\n", "os.system('shasum -c %s.sha256' % VAR_16)\n", "os.system('shasum -c %s.asc.sha256' % VAR_16)\n", "os.system('gpg --verify %s.asc %s' % (VAR_16, VAR_16))\n", "os.system('keybase verify %s.asc' % VAR_16)\n", "def FUNC_2(VAR_1, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "print(' Unpacking %s...' % VAR_1)\n", "os.system('tar xf ' + VAR_1)\n", "VAR_17 = VAR_1.split('.tar')[0]\n", "print(' Installing %s...' % VAR_17)\n", "VAR_18 = '--prefix=${PWD}/%s --disable-ldconfig' % VAR_2\n", "os.system('%s/install.sh %s' % (VAR_17, VAR_18))\n", "print(' Cleaning %s...' % VAR_17)\n", "os.system('rm -rf %s' % VAR_17)\n", "def FUNC_3(VAR_3, VAR_4, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "VAR_19 = VAR_3['pkg'][VAR_4]['version']\n", "VAR_20 = VAR_3['pkg'][VAR_4]['target'][VAR_2]\n", "return VAR_19, VAR_20\n" ]
[ "\"\"\"\nThis script downloads and repacks official rust language builds\nwith the necessary tool and target support for the Firefox\nbuild environment.\n\"\"\"\n", "import requests\n", "import toml\n", "import os\n", "def fetch_file(url):...\n", "\"\"\"docstring\"\"\"\n", "filename = os.path.basename(url)\n", "if os.path.exists(filename):\n", "return\n", "r = requests.get(url, stream=True)\n", "r.raise_for_status()\n", "for chunk in r.iter_content(4096):\n", "fd.write(chunk)\n", "def fetch(url):...\n", "\"\"\"docstring\"\"\"\n", "base = os.path.basename(url)\n", "print('Fetching %s...' % base)\n", "fetch_file(url + '.asc')\n", "fetch_file(url)\n", "fetch_file(url + '.sha256')\n", "fetch_file(url + '.asc.sha256')\n", "print('Verifying %s...' % base)\n", "os.system('shasum -c %s.sha256' % base)\n", "os.system('shasum -c %s.asc.sha256' % base)\n", "os.system('gpg --verify %s.asc %s' % (base, base))\n", "os.system('keybase verify %s.asc' % base)\n", "def install(filename, target):...\n", "\"\"\"docstring\"\"\"\n", "print(' Unpacking %s...' % filename)\n", "os.system('tar xf ' + filename)\n", "basename = filename.split('.tar')[0]\n", "print(' Installing %s...' % basename)\n", "install_opts = '--prefix=${PWD}/%s --disable-ldconfig' % target\n", "os.system('%s/install.sh %s' % (basename, install_opts))\n", "print(' Cleaning %s...' % basename)\n", "os.system('rm -rf %s' % basename)\n", "def package(manifest, pkg, target):...\n", "\"\"\"docstring\"\"\"\n", "version = manifest['pkg'][pkg]['version']\n", "info = manifest['pkg'][pkg]['target'][target]\n", "return version, info\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 2, 0, 0, 2, 2, 0, 2, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "Import'", "Import'", "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'", "Assign'", "Expr'", "For", "Expr'", "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Docstring", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_15(self, VAR_9):...\n", "\"\"\"docstring\"\"\"\n", "VAR_19 = self.session.query(self.resource_type).get(VAR_9)\n", "if VAR_19 is None:\n", "VAR_19.deleted = True\n" ]
[ "def delete(self, model_id):...\n", "\"\"\"docstring\"\"\"\n", "model = self.session.query(self.resource_type).get(model_id)\n", "if model is None:\n", "model.deleted = True\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'" ]
[ "def FUNC_32(self, VAR_32, VAR_29):...\n", "\"\"\"docstring\"\"\"\n", "VAR_24 = self.getfile(VAR_32)\n", "if VAR_24 == False:\n", "return\n", "if VAR_24[VAR_2] != VAR_13:\n", "return\n", "VAR_24[VAR_5] = VAR_29\n" ]
[ "def update_size(self, filename, size):...\n", "\"\"\"docstring\"\"\"\n", "f = self.getfile(filename)\n", "if f == False:\n", "return\n", "if f[A_TYPE] != T_FILE:\n", "return\n", "f[A_SIZE] = size\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'", "Condition", "Return'", "Assign'" ]
[ "def FUNC_1(self):...\n", "VAR_1 = self.c.get('/find/?q=ethyl')\n", "self.assertContains(VAR_1, 'Data Document')\n", "self.assertNotContains(VAR_1, 'Extracted Chemical')\n", "self.assertNotContains(VAR_1, 'DSSTox Substance')\n" ]
[ "def test_faceted_search_excludes_chemicals(self):...\n", "response = self.c.get('/find/?q=ethyl')\n", "self.assertContains(response, 'Data Document')\n", "self.assertNotContains(response, 'Extracted Chemical')\n", "self.assertNotContains(response, 'DSSTox Substance')\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_2():...\n", "if VAR_9 == '':\n", "VAR_3 = VAR_0\n", "if VAR_9 in VAR_1:\n", "VAR_2 = VAR_0\n", "VAR_3.append(VAR_9)\n", "if VAR_9 == '..':\n", "VAR_2.clear()\n", "VAR_3.pop()\n", "print(\"Directory doesn't exist.\")\n", "print(*VAR_3, sep='/')\n", "VAR_10 = len(VAR_1) - 1\n", "if VAR_1[VAR_10] in VAR_2:\n", "VAR_10 = VAR_10 - 1\n", "VAR_2.append(VAR_1[VAR_10])\n", "VAR_2.pop()\n", "VAR_2.append(VAR_1[VAR_10])\n" ]
[ "def cd():...\n", "if dir == '':\n", "curr_path = root\n", "if dir in dirs:\n", "path = root\n", "curr_path.append(dir)\n", "if dir == '..':\n", "path.clear()\n", "curr_path.pop()\n", "print(\"Directory doesn't exist.\")\n", "print(*curr_path, sep='/')\n", "i = len(dirs) - 1\n", "if dirs[i] in path:\n", "i = i - 1\n", "path.append(dirs[i])\n", "path.pop()\n", "path.append(dirs[i])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_28(self, *VAR_76, **VAR_52):...\n", "def FUNC_39(VAR_101):...\n", "VAR_101.resources = VAR_76, VAR_52\n", "return VAR_101\n" ]
[ "def resources(self, *args, **resources):...\n", "def decorate(ruleinfo):...\n", "ruleinfo.resources = args, resources\n", "return ruleinfo\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_1(VAR_6, VAR_2=None):...\n", "if VAR_2 is None:\n", "VAR_2 = VAR_0\n", "return VAR_2.filter(content_type=get_ct(object), object_id=object.id)\n" ]
[ "def get_articles_for_object(object, article_qs=None):...\n", "if article_qs is None:\n", "article_qs = ALL_ARTICLES\n", "return article_qs.filter(content_type=get_ct(object), object_id=object.id)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_7(self, VAR_11):...\n", "\"\"\"docstring\"\"\"\n" ]
[ "def create_snapshot(self, snapshot):...\n", "\"\"\"docstring\"\"\"\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Docstring" ]
[ "@VAR_3.callback_query_handler(func=lambda call: True)...\n", "VAR_10 = VAR_9.from_user.id\n", "VAR_29 = VAR_9.data[:1]\n", "VAR_30 = VAR_9.data[1:]\n", "if VAR_9.data == '..':\n", "VAR_1[VAR_10].go_to_parent_directory()\n", "if VAR_29 == 'd':\n", "FUNC_7(VAR_10, VAR_3)\n", "VAR_1[VAR_10].go_to_directory(VAR_30)\n", "if VAR_29 == 'f':\n", "VAR_30 = VAR_0.select('file', 'id = ' + VAR_30)[0]['telegram_id']\n", "if VAR_29 == 'r':\n", "VAR_3.forward_message(VAR_10, VAR_10, VAR_30)\n", "VAR_42 = VAR_30[:1] == 'd'\n", "VAR_30 = VAR_30[1:]\n", "if VAR_42:\n", "VAR_1[VAR_10].remove_directories([VAR_30])\n", "VAR_1[VAR_10].remove_files([VAR_30])\n" ]
[ "@bot.callback_query_handler(func=lambda call: True)...\n", "telegram_id = call.from_user.id\n", "action = call.data[:1]\n", "content_id = call.data[1:]\n", "if call.data == '..':\n", "explorers[telegram_id].go_to_parent_directory()\n", "if action == 'd':\n", "send_replacing_message(telegram_id, bot)\n", "explorers[telegram_id].go_to_directory(content_id)\n", "if action == 'f':\n", "content_id = db.select('file', 'id = ' + content_id)[0]['telegram_id']\n", "if action == 'r':\n", "bot.forward_message(telegram_id, telegram_id, content_id)\n", "is_directory = content_id[:1] == 'd'\n", "content_id = content_id[1:]\n", "if is_directory:\n", "explorers[telegram_id].remove_directories([content_id])\n", "explorers[telegram_id].remove_files([content_id])\n" ]
[ 0, 0, 0, 0, 0, 4, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 4, 4 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._server\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._server\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]