code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def rpc_campaign_landing_page_new(handler, session, campaign_id, hostname, page):
"""
Add a landing page for the specified campaign. Landing pages refer
to resources that when visited by a user should cause the visit
counter to be incremented.
:param int campaign_id: The ID of the campaign.
:param str hostname: ... |
Add a landing page for the specified campaign. Landing pages refer
to resources that when visited by a user should cause the visit
counter to be incremented.
:param int campaign_id: The ID of the campaign.
:param str hostname: The hostname which will be used to serve the request.
:param str page: The request re... | rpc_campaign_landing_page_new | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_campaign_message_new(handler, session, campaign_id, email_id, target_email, first_name, last_name, department_name=None):
"""
Record a message that has been sent as part of a campaign. These details can
be retrieved later for value substitution in template pages.
:param int campaign_id: The ID of the campa... |
Record a message that has been sent as part of a campaign. These details can
be retrieved later for value substitution in template pages.
:param int campaign_id: The ID of the campaign.
:param str email_id: The message id of the sent email.
:param str target_email: The email address that the message was sent to.... | rpc_campaign_message_new | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_campaign_message_new(handler, session, campaign_id, email_id, target_email, first_name, last_name, department_name=None):
"""
Record a message that has been sent as part of a campaign. These details can
be retrieved later for value substitution in template pages.
:param int campaign_id: The ID of the campa... |
Record a message that has been sent as part of a campaign. These details can
be retrieved later for value substitution in template pages.
:param int campaign_id: The ID of the campaign.
:param str email_id: The message id of the sent email.
:param str target_email: The email address that the message was sent to.... | rpc_campaign_message_new | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_campaign_stats(handler, session, campaign_id):
"""
Generate statistics regarding the specified campaign and return them in a
dictionary. The dictionary will contain the keys credentials,
credentials-unique, messages, messages-trained, visits, visits-unique.
Values with unique in the key are counted unique ... |
Generate statistics regarding the specified campaign and return them in a
dictionary. The dictionary will contain the keys credentials,
credentials-unique, messages, messages-trained, visits, visits-unique.
Values with unique in the key are counted unique by the message id for
which they are associated.
:param ... | rpc_campaign_stats | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_database_count_rows(handler, session, table_name, query_filter=None):
"""
Get a count of the rows in the specified table where the search
criteria matches.
:param str table_name: The name of the database table to query.
:param dict query_filter: A dictionary mapping optional search criteria for matching t... |
Get a count of the rows in the specified table where the search
criteria matches.
:param str table_name: The name of the database table to query.
:param dict query_filter: A dictionary mapping optional search criteria for matching the query.
:return: The number of matching rows.
:rtype: int
| rpc_database_count_rows | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_database_view_rows(handler, session, table_name, page=0, query_filter=None):
"""
Retrieve the rows from the specified table where the search
criteria matches.
:param str table_name: The name of the database table to query.
:param int page: The page number to retrieve results for.
:param dict query_filter... |
Retrieve the rows from the specified table where the search
criteria matches.
:param str table_name: The name of the database table to query.
:param int page: The page number to retrieve results for.
:param dict query_filter: A dictionary mapping optional search criteria for matching the query.
:return: A dicti... | rpc_database_view_rows | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_database_delete_row_by_id(handler, session, table_name, row_id):
"""
Delete the row from the table with the specified value in the id column.
If the row does not exist, no error is raised.
:param str table_name: The name of the database table to delete a row from.
:param row_id: The id value.
"""
metata... |
Delete the row from the table with the specified value in the id column.
If the row does not exist, no error is raised.
:param str table_name: The name of the database table to delete a row from.
:param row_id: The id value.
| rpc_database_delete_row_by_id | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_database_delete_rows_by_id(handler, session, table_name, row_ids):
"""
Delete multiple rows from a table with the specified values in the id
column. If a row id specified in *row_ids* does not exist, then it will
be skipped and no error will be thrown.
:param str table_name: The name of the database table... |
Delete multiple rows from a table with the specified values in the id
column. If a row id specified in *row_ids* does not exist, then it will
be skipped and no error will be thrown.
:param str table_name: The name of the database table to delete rows from.
:param list row_ids: The row ids to delete.
:return: Th... | rpc_database_delete_rows_by_id | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_database_get_row_by_id(handler, session, table_name, row_id):
"""
Retrieve a row from a given table with the specified value in the
id column.
:param str table_name: The name of the database table to retrieve a row from.
:param row_id: The id value.
:return: The specified row data.
:rtype: dict
"""
me... |
Retrieve a row from a given table with the specified value in the
id column.
:param str table_name: The name of the database table to retrieve a row from.
:param row_id: The id value.
:return: The specified row data.
:rtype: dict
| rpc_database_get_row_by_id | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_database_insert_row(handler, session, table_name, keys, values):
"""
Insert a new row into the specified table.
:param str table_name: The name of the database table to insert a new row into.
:param list keys: The column names of *values*.
:param list values: The values to be inserted in the row.
:return... |
Insert a new row into the specified table.
:param str table_name: The name of the database table to insert a new row into.
:param list keys: The column names of *values*.
:param list values: The values to be inserted in the row.
:return: The id of the new row that has been added.
| rpc_database_insert_row | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_database_insert_row_multi(handler, session, table_name, keys, rows, deconflict_ids=False):
"""
Insert multiple new rows into the specified table. If *deconflict_ids* is
true, new id values will be assigned as necessary to merge the data into
the database. This function will fail if constraints for the table... |
Insert multiple new rows into the specified table. If *deconflict_ids* is
true, new id values will be assigned as necessary to merge the data into
the database. This function will fail if constraints for the table are
not met.
:param str table_name: The name of the database table to insert data into.
:param lis... | rpc_database_insert_row_multi | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_database_set_row_value(handler, session, table_name, row_id, keys, values):
"""
Set values for a row in the specified table with an id of *row_id*.
:param str table_name: The name of the database table to set the values of the specified row.
:param tuple keys: The column names of *values*.
:param tuple va... |
Set values for a row in the specified table with an id of *row_id*.
:param str table_name: The name of the database table to set the values of the specified row.
:param tuple keys: The column names of *values*.
:param tuple values: The values to be updated in the row.
| rpc_database_set_row_value | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_events_is_subscribed(handler, event_id, event_type):
"""
Check if the client is currently subscribed to the specified server event.
:param str event_id: The identifier of the event to subscribe to.
:param str event_type: A sub-type for the corresponding event.
:return: Whether or not the client is subscri... |
Check if the client is currently subscribed to the specified server event.
:param str event_id: The identifier of the event to subscribe to.
:param str event_type: A sub-type for the corresponding event.
:return: Whether or not the client is subscribed to the event.
:rtype: bool
| rpc_events_is_subscribed | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_events_subscribe(handler, event_id, event_types=None, attributes=None):
"""
Subscribe the client to the specified event published by the server.
When the event is published the specified *attributes* of it and it's
corresponding id and type information will be sent to the client.
:param str event_id: The ... |
Subscribe the client to the specified event published by the server.
When the event is published the specified *attributes* of it and it's
corresponding id and type information will be sent to the client.
:param str event_id: The identifier of the event to subscribe to.
:param list event_types: A list of sub-typ... | rpc_events_subscribe | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_events_unsubscribe(handler, event_id, event_types=None, attributes=None):
"""
Unsubscribe from an event published by the server that the client
previously subscribed to.
:param str event_id: The identifier of the event to subscribe to.
:param list event_types: A list of sub-types for the corresponding eve... |
Unsubscribe from an event published by the server that the client
previously subscribed to.
:param str event_id: The identifier of the event to subscribe to.
:param list event_types: A list of sub-types for the corresponding event.
:param list attributes: A list of attributes of the event object to be sent to th... | rpc_events_unsubscribe | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_geoip_lookup(handler, ip, lang=None):
"""
Look up an IP address in the servers GeoIP database. If the IP address
can not be found in the database, None will be returned.
:param str ip: The IP address to look up.
:param str lang: The language to prefer for regional names.
:return: The geographic informati... |
Look up an IP address in the servers GeoIP database. If the IP address
can not be found in the database, None will be returned.
:param str ip: The IP address to look up.
:param str lang: The language to prefer for regional names.
:return: The geographic information for the specified IP address.
:rtype: dict
| rpc_geoip_lookup | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_geoip_lookup_multi(handler, ips, lang=None):
"""
Look up multiple IP addresses in the servers GeoIP database. Each IP
address that can not be found in the database will have its result set
to None.
:param list ips: The list of IP addresses to look up.
:param str lang: The language to prefer for regional ... |
Look up multiple IP addresses in the servers GeoIP database. Each IP
address that can not be found in the database will have its result set
to None.
:param list ips: The list of IP addresses to look up.
:param str lang: The language to prefer for regional names.
:return: A dictionary containing the results keye... | rpc_geoip_lookup_multi | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_hostnames_add(handler, hostname):
"""
Add a hostname to the list of values that are configured for use with this
server. At this time, these changes (like other config changes) are not
persisted in the server so they will be lost when the server reboots.
.. versionadded:: 1.13.0
:param str hostname: The... |
Add a hostname to the list of values that are configured for use with this
server. At this time, these changes (like other config changes) are not
persisted in the server so they will be lost when the server reboots.
.. versionadded:: 1.13.0
:param str hostname: The hostname to add.
| rpc_hostnames_add | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_plugins_list(handler):
"""
Return information regarding enabled plugins in the server.
:return: A dictionary representing enabled plugins and their meta-data.
:rtype: dict
"""
plugin_manager = handler.server.plugin_manager
plugins = {}
for _, plugin in plugin_manager:
plugins[plugin.name] = {
'aut... |
Return information regarding enabled plugins in the server.
:return: A dictionary representing enabled plugins and their meta-data.
:rtype: dict
| rpc_plugins_list | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_graphql(handler, session, query, query_vars=None):
"""
Execute a GraphQL query and return the results. If the query fails to
execute the errors returned are populated in the **errors** key of the
results dictionary. If the query executes successfully the returned data
is available in the **data** key of th... |
Execute a GraphQL query and return the results. If the query fails to
execute the errors returned are populated in the **errors** key of the
results dictionary. If the query executes successfully the returned data
is available in the **data** key of the results dictionary.
:param str query: The GraphQL query to ... | rpc_graphql | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_ssl_letsencrypt_certbot_version(handler):
"""
Find the certbot binary and retrieve it's version information. If the
certbot binary could not be found, ``None`` is returned.
.. versionadded:: 1.14.0
:return: The version of certbot.
:rtype: str
"""
bin_path = letsencrypt.get_certbot_bin_path(handler.con... |
Find the certbot binary and retrieve it's version information. If the
certbot binary could not be found, ``None`` is returned.
.. versionadded:: 1.14.0
:return: The version of certbot.
:rtype: str
| rpc_ssl_letsencrypt_certbot_version | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_ssl_letsencrypt_issue(handler, hostname, load=True):
"""
Issue a certificate with Let's Encrypt. This operation can fail for a wide
variety of reasons, check the ``message`` key of the returned dictionary for
a string description of what occurred. Successful operation requires that
the certbot utility be i... |
Issue a certificate with Let's Encrypt. This operation can fail for a wide
variety of reasons, check the ``message`` key of the returned dictionary for
a string description of what occurred. Successful operation requires that
the certbot utility be installed, and the server's Let's Encrypt data path
is configured... | rpc_ssl_letsencrypt_issue | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_ssl_sni_hostnames_get(handler):
"""
Get the hostnames that have available Server Name Indicator (SNI)
configurations for use with SSL.
.. versionadded:: 1.14.0
:return: A dictionary keyed by hostnames with values of dictionaries containing additional metadata.
:rtype: dict
"""
if not advancedhttpserve... |
Get the hostnames that have available Server Name Indicator (SNI)
configurations for use with SSL.
.. versionadded:: 1.14.0
:return: A dictionary keyed by hostnames with values of dictionaries containing additional metadata.
:rtype: dict
| rpc_ssl_sni_hostnames_get | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_ssl_sni_hostnames_load(handler, hostname):
"""
Load the SNI configuration for the specified *hostname*, effectively
enabling it. If SSL is not enabled, SNI is not available, or the necessary
data files are not available, this function returns ``False``.
.. versionadded:: 1.14.0
:param str hostname: The ... |
Load the SNI configuration for the specified *hostname*, effectively
enabling it. If SSL is not enabled, SNI is not available, or the necessary
data files are not available, this function returns ``False``.
.. versionadded:: 1.14.0
:param str hostname: The hostname to configure SSL for.
:return: Returns ``True... | rpc_ssl_sni_hostnames_load | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_ssl_sni_hostnames_unload(handler, hostname):
"""
Unload the SNI configuration for the specified *hostname*, effectively
disabling it. If SNI is not available, or the specified configuration was
not already loaded, this function returns ``False``.
.. versionadded:: 1.14.0
:param str hostname: The hostnam... |
Unload the SNI configuration for the specified *hostname*, effectively
disabling it. If SNI is not available, or the specified configuration was
not already loaded, this function returns ``False``.
.. versionadded:: 1.14.0
:param str hostname: The hostname to configure SSL for.
:return: Returns ``True`` only i... | rpc_ssl_sni_hostnames_unload | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def rpc_ssl_status(handler):
"""
Get information regarding the status of SSL on the server. This method
returns a dictionary with keys describing whether or not SSL is enabled on
one or more interfaces, and whether or not the server possess the SNI
support. For details regarding which addresses are using SSL, see ... |
Get information regarding the status of SSL on the server. This method
returns a dictionary with keys describing whether or not SSL is enabled on
one or more interfaces, and whether or not the server possess the SNI
support. For details regarding which addresses are using SSL, see the
:py:func:`~rpc_config_get` m... | rpc_ssl_status | python | rsmusllp/king-phisher | king_phisher/server/server_rpc.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/server_rpc.py | BSD-3-Clause |
def embed_youtube_video(video_id, autoplay=True, enable_js=False, start=0, end=None):
"""
A Jinja function to embed a video into a web page using YouTube's
`iframe API <https://developers.google.com/youtube/iframe_api_reference>`_.
In order to enable a training button after the video has ended the
youtube.js file ... |
A Jinja function to embed a video into a web page using YouTube's
`iframe API <https://developers.google.com/youtube/iframe_api_reference>`_.
In order to enable a training button after the video has ended the
youtube.js file needs to be included and *enable_js* just be set to True. If
*start* or *end* are specifi... | embed_youtube_video | python | rsmusllp/king-phisher | king_phisher/server/template_extras.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/template_extras.py | BSD-3-Clause |
def make_redirect_page(url, title='Automatic Redirect'):
"""
A Jinja function which will create an HTML page that will automatically
redirect the viewer to a different url.
:param str url: The URL to redirect the user to.
:param str title: The title to use in the resulting HTML page.
"""
title = html.escape(tit... |
A Jinja function which will create an HTML page that will automatically
redirect the viewer to a different url.
:param str url: The URL to redirect the user to.
:param str title: The title to use in the resulting HTML page.
| make_redirect_page | python | rsmusllp/king-phisher | king_phisher/server/template_extras.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/template_extras.py | BSD-3-Clause |
def __init__(self, handler, manager):
"""
:param handler: The request handler that should be used by this socket.
:type handler: :py:class:`advancedhttpserver.RequestHandler`
:param manager: The manager that this event socket should register with.
:type manager: :py:class:`.WebSocketsManager`
"""
handler.... |
:param handler: The request handler that should be used by this socket.
:type handler: :py:class:`advancedhttpserver.RequestHandler`
:param manager: The manager that this event socket should register with.
:type manager: :py:class:`.WebSocketsManager`
| __init__ | python | rsmusllp/king-phisher | king_phisher/server/web_sockets.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_sockets.py | BSD-3-Clause |
def is_subscribed(self, event_id, event_type):
"""
Check if the client is currently subscribed to the specified server event.
:param str event_id: The identifier of the event to subscribe to.
:param str event_type: A sub-type for the corresponding event.
:return: Whether or not the client is subscribed to th... |
Check if the client is currently subscribed to the specified server event.
:param str event_id: The identifier of the event to subscribe to.
:param str event_type: A sub-type for the corresponding event.
:return: Whether or not the client is subscribed to the event.
:rtype: bool
| is_subscribed | python | rsmusllp/king-phisher | king_phisher/server/web_sockets.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_sockets.py | BSD-3-Clause |
def publish(self, event):
"""
Publish the event by sending the relevant information to the client.
If the client has not requested to receive the information through a
subscription, then no data will be sent.
:param event: The object representing the data to be published.
:type event: :py:class:`.Event`
... |
Publish the event by sending the relevant information to the client.
If the client has not requested to receive the information through a
subscription, then no data will be sent.
:param event: The object representing the data to be published.
:type event: :py:class:`.Event`
| publish | python | rsmusllp/king-phisher | king_phisher/server/web_sockets.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_sockets.py | BSD-3-Clause |
def subscribe(self, event_id, event_types=None, attributes=None):
"""
Subscribe the client to the specified event published by the server.
When the event is published the specified *attributes* of it and it's
corresponding id and type information will be sent to the client.
:param str event_id: The identifie... |
Subscribe the client to the specified event published by the server.
When the event is published the specified *attributes* of it and it's
corresponding id and type information will be sent to the client.
:param str event_id: The identifier of the event to subscribe to.
:param list event_types: A list of su... | subscribe | python | rsmusllp/king-phisher | king_phisher/server/web_sockets.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_sockets.py | BSD-3-Clause |
def unsubscribe(self, event_id, event_types=None, attributes=None):
"""
Unsubscribe from an event published by the server that the client
previously subscribed to.
:param str event_id: The identifier of the event to subscribe to.
:param list event_types: A list of sub-types for the corresponding event.
:pa... |
Unsubscribe from an event published by the server that the client
previously subscribed to.
:param str event_id: The identifier of the event to subscribe to.
:param list event_types: A list of sub-types for the corresponding event.
:param list attributes: A list of attributes of the event object to be sent ... | unsubscribe | python | rsmusllp/king-phisher | king_phisher/server/web_sockets.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_sockets.py | BSD-3-Clause |
def __init__(self, config, job_manager):
"""
:param config: Configuration to retrieve settings from.
:type config: :py:class:`smoke_zephyr.configuration.Configuration`
:param job_manager: A job manager instance that can be used to schedule tasks.
:type job_manager: :py:class:`smoke_zephyr.job.JobManager`
""... |
:param config: Configuration to retrieve settings from.
:type config: :py:class:`smoke_zephyr.configuration.Configuration`
:param job_manager: A job manager instance that can be used to schedule tasks.
:type job_manager: :py:class:`smoke_zephyr.job.JobManager`
| __init__ | python | rsmusllp/king-phisher | king_phisher/server/web_sockets.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_sockets.py | BSD-3-Clause |
def dispatch(self, handler):
"""
A method that is suitable for use as a
:py:attr:`~advancedhttpserver.RequestHandler.web_socket_handler`.
:param handler: The current request handler instance.
:type handler: :py:class:`~king_phisher.server.server.KingPhisherRequestHandler`
"""
if not ipaddress.ip_address(... |
A method that is suitable for use as a
:py:attr:`~advancedhttpserver.RequestHandler.web_socket_handler`.
:param handler: The current request handler instance.
:type handler: :py:class:`~king_phisher.server.server.KingPhisherRequestHandler`
| dispatch | python | rsmusllp/king-phisher | king_phisher/server/web_sockets.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_sockets.py | BSD-3-Clause |
def ping_all(self):
"""
Ping all of the connected web sockets to ensure they stay alive. This
method is automatically executed periodically through a job added when
the manager is initialized.
"""
disconnected = collections.deque()
for web_socket in self.web_sockets:
if web_socket.connected:
try:
... |
Ping all of the connected web sockets to ensure they stay alive. This
method is automatically executed periodically through a job added when
the manager is initialized.
| ping_all | python | rsmusllp/king-phisher | king_phisher/server/web_sockets.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_sockets.py | BSD-3-Clause |
def stop(self):
"""
Shutdown the manager and clean up the resources it has allocated.
"""
self.job_manager.job_delete(self._ping_job)
for web_socket in self.web_sockets:
if web_socket.connected:
web_socket.close()
self.web_sockets = []
self._work_queue.put(None)
self._worker_thread.join() |
Shutdown the manager and clean up the resources it has allocated.
| stop | python | rsmusllp/king-phisher | king_phisher/server/web_sockets.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_sockets.py | BSD-3-Clause |
def get_hostnames(config):
"""
List the hostnames that are configured for this server instance. This list
is generated by first checking the server's configuration for the
``hostnames`` option. Then if ``vhost_directories`` is enabled, the webroot
is checked for additional values.
.. note::
This function makes... |
List the hostnames that are configured for this server instance. This list
is generated by first checking the server's configuration for the
``hostnames`` option. Then if ``vhost_directories`` is enabled, the webroot
is checked for additional values.
.. note::
This function makes no attempt to validate these v... | get_hostnames | python | rsmusllp/king-phisher | king_phisher/server/web_tools.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_tools.py | BSD-3-Clause |
def get_vhost_directories(config):
"""
List the hostnames that are configured through the Virtual Host directories.
If the server option ``vhost_directories`` is disabled, this function
returns ``None``.
.. versionadded:: 1.13.0
:param config: Configuration to retrieve settings from.
:type config: :py:class:`s... |
List the hostnames that are configured through the Virtual Host directories.
If the server option ``vhost_directories`` is disabled, this function
returns ``None``.
.. versionadded:: 1.13.0
:param config: Configuration to retrieve settings from.
:type config: :py:class:`smoke_zephyr.configuration.Configuration... | get_vhost_directories | python | rsmusllp/king-phisher | king_phisher/server/web_tools.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/web_tools.py | BSD-3-Clause |
def _ex_config_logging(arguments, config, console_handler):
"""
If a setting is configured improperly, this will terminate execution via
:py:func:`sys.exit`.
:return: The path to a log file if one is in use.
:rtype: str
"""
default_log_level = min(
getattr(logging, (arguments.loglvl or constants.DEFAULT_LOG_L... |
If a setting is configured improperly, this will terminate execution via
:py:func:`sys.exit`.
:return: The path to a log file if one is in use.
:rtype: str
| _ex_config_logging | python | rsmusllp/king-phisher | king_phisher/server/__main__.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/__main__.py | BSD-3-Clause |
def clear_database():
"""
Delete all data from all tables in the connected database. The database
schema will remain unaffected.
.. warning::
This action can not be reversed and there is no confirmation before it
takes place.
"""
engine = Session.connection().engine
with contextlib.closing(engine.connect())... |
Delete all data from all tables in the connected database. The database
schema will remain unaffected.
.. warning::
This action can not be reversed and there is no confirmation before it
takes place.
| clear_database | python | rsmusllp/king-phisher | king_phisher/server/database/manager.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/manager.py | BSD-3-Clause |
def export_database(target_file):
"""
Export the contents of the database using SQLAlchemy's serialization. This
creates an archive file containing all of the tables and their data. The
resulting export can be imported into another supported database so long
as the :py:data:`~king_phisher.server.database.models.SC... |
Export the contents of the database using SQLAlchemy's serialization. This
creates an archive file containing all of the tables and their data. The
resulting export can be imported into another supported database so long
as the :py:data:`~king_phisher.server.database.models.SCHEMA_VERSION` is the
same.
:param s... | export_database | python | rsmusllp/king-phisher | king_phisher/server/database/manager.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/manager.py | BSD-3-Clause |
def import_database(target_file, clear=True):
"""
Import the contents of a serialized database from an archive previously
created with the :py:func:`.export_database` function. The current
:py:data:`~king_phisher.server.database.models.SCHEMA_VERSION` must be the
same as the exported archive.
.. warning::
This... |
Import the contents of a serialized database from an archive previously
created with the :py:func:`.export_database` function. The current
:py:data:`~king_phisher.server.database.models.SCHEMA_VERSION` must be the
same as the exported archive.
.. warning::
This will by default delete the contents of the curren... | import_database | python | rsmusllp/king-phisher | king_phisher/server/database/manager.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/manager.py | BSD-3-Clause |
def get_metadata(key, session=None):
"""
Store a piece of metadata regarding the King Phisher database.
:param str key: The name of the data.
:param value: The value to store.
:type value: int, str
:param session: The session to use to store the value.
"""
if not isinstance(key, str):
raise TypeError('key mu... |
Store a piece of metadata regarding the King Phisher database.
:param str key: The name of the data.
:param value: The value to store.
:type value: int, str
:param session: The session to use to store the value.
| get_metadata | python | rsmusllp/king-phisher | king_phisher/server/database/manager.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/manager.py | BSD-3-Clause |
def get_row_by_id(session, table, row_id):
"""
Retrieve a database row from the specified table by it's unique id.
:param session: The database session to use for the query.
:type session: `.Session`
:param table: The table object or the name of the database table where the row resides.
:param row_id: The id of ... |
Retrieve a database row from the specified table by it's unique id.
:param session: The database session to use for the query.
:type session: `.Session`
:param table: The table object or the name of the database table where the row resides.
:param row_id: The id of the row to retrieve.
:return: The object repre... | get_row_by_id | python | rsmusllp/king-phisher | king_phisher/server/database/manager.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/manager.py | BSD-3-Clause |
def set_metadata(key, value, session=None):
"""
Store a piece of metadata regarding the King Phisher database.
:param str key: The name of the data.
:param value: The value to store.
:type value: int, str
:param session: The session to use to store the value.
"""
if not isinstance(key, str):
raise TypeError(... |
Store a piece of metadata regarding the King Phisher database.
:param str key: The name of the data.
:param value: The value to store.
:type value: int, str
:param session: The session to use to store the value.
| set_metadata | python | rsmusllp/king-phisher | king_phisher/server/database/manager.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/manager.py | BSD-3-Clause |
def normalize_connection_url(connection_url):
"""
Normalize a connection url by performing any conversions necessary for it to
be used with the database API.
:param str connection_url: The connection url to normalize.
:return: The normalized connection url.
:rtype: str
"""
if connection_url == ':memory:':
co... |
Normalize a connection url by performing any conversions necessary for it to
be used with the database API.
:param str connection_url: The connection url to normalize.
:return: The normalized connection url.
:rtype: str
| normalize_connection_url | python | rsmusllp/king-phisher | king_phisher/server/database/manager.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/manager.py | BSD-3-Clause |
def init_alembic(engine, schema_version):
"""
Creates the alembic_version table and sets the value of the table according
to the specified schema version.
:param engine: The engine used to connect to the database.
:type engine: :py:class:`sqlalchemy.engine.Engine`
:param int schema_version: The MetaData schema_v... |
Creates the alembic_version table and sets the value of the table according
to the specified schema version.
:param engine: The engine used to connect to the database.
:type engine: :py:class:`sqlalchemy.engine.Engine`
:param int schema_version: The MetaData schema_version to set the alembic version to.
| init_alembic | python | rsmusllp/king-phisher | king_phisher/server/database/manager.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/manager.py | BSD-3-Clause |
def init_database(connection_url, extra_init=False):
"""
Create and initialize the database engine. This must be done before the
session object can be used. This will also attempt to perform any updates to
the database schema if the backend supports such operations.
:param str connection_url: The url for the data... |
Create and initialize the database engine. This must be done before the
session object can be used. This will also attempt to perform any updates to
the database schema if the backend supports such operations.
:param str connection_url: The url for the database connection.
:param bool extra_init: Run optional ex... | init_database | python | rsmusllp/king-phisher | king_phisher/server/database/manager.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/manager.py | BSD-3-Clause |
def init_database_postgresql(connection_url):
"""
Perform additional initialization checks and operations for a PostgreSQL
database. If the database is hosted locally this will ensure that the
service is currently running and start it if it is not. Additionally if the
specified database or user do not exist, they ... |
Perform additional initialization checks and operations for a PostgreSQL
database. If the database is hosted locally this will ensure that the
service is currently running and start it if it is not. Additionally if the
specified database or user do not exist, they will be created.
:param connection_url: The url ... | init_database_postgresql | python | rsmusllp/king-phisher | king_phisher/server/database/manager.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/manager.py | BSD-3-Clause |
def register_table(table):
"""
Register a database table. This will populate the information provided in
DATABASE_TABLES dictionary. This also forwards signals to the appropriate
listeners within the :py:mod:`server.signal` module.
:param cls table: The table to register.
"""
metatable = table.metatable()
data... |
Register a database table. This will populate the information provided in
DATABASE_TABLES dictionary. This also forwards signals to the appropriate
listeners within the :py:mod:`server.signal` module.
:param cls table: The table to register.
| register_table | python | rsmusllp/king-phisher | king_phisher/server/database/models.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/models.py | BSD-3-Clause |
def assert_session_has_permissions(self, *args, **kwargs):
"""
A convenience function which wraps :py:meth:`~.session_has_permissions`
and raises a :py:exc:`~king_phisher.errors.KingPhisherPermissionError`
if the session does not have the specified permissions.
"""
if self.session_has_permissions(*args, **k... |
A convenience function which wraps :py:meth:`~.session_has_permissions`
and raises a :py:exc:`~king_phisher.errors.KingPhisherPermissionError`
if the session does not have the specified permissions.
| assert_session_has_permissions | python | rsmusllp/king-phisher | king_phisher/server/database/models.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/models.py | BSD-3-Clause |
def session_has_permissions(self, access, session):
"""
Check that the authenticated session has the permissions specified in
*access*. The permissions in *access* are abbreviated with the first
letter of create, read, update, and delete. For example, to check for
read and update permissions, *access* would b... |
Check that the authenticated session has the permissions specified in
*access*. The permissions in *access* are abbreviated with the first
letter of create, read, update, and delete. For example, to check for
read and update permissions, *access* would be ``'ru'``.
.. note::
This will always return ``Tru... | session_has_permissions | python | rsmusllp/king-phisher | king_phisher/server/database/models.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/models.py | BSD-3-Clause |
def session_has_create_access(cls, session, instance=None):
"""
Check that the authenticated *session* has access to create the
specified model *instance*.
:param session: The authenticated session to check access for.
:param instance: The optional model instance to inspect.
:return: Whether the session ha... |
Check that the authenticated *session* has access to create the
specified model *instance*.
:param session: The authenticated session to check access for.
:param instance: The optional model instance to inspect.
:return: Whether the session has the desired permissions.
:rtype: bool
| session_has_create_access | python | rsmusllp/king-phisher | king_phisher/server/database/models.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/models.py | BSD-3-Clause |
def session_has_delete_access(cls, session, instance=None):
"""
Check that the authenticated *session* has access to delete the
specified model *instance*.
:param session: The authenticated session to check access for.
:param instance: The optional model instance to inspect.
:return: Whether the session ha... |
Check that the authenticated *session* has access to delete the
specified model *instance*.
:param session: The authenticated session to check access for.
:param instance: The optional model instance to inspect.
:return: Whether the session has the desired permissions.
:rtype: bool
| session_has_delete_access | python | rsmusllp/king-phisher | king_phisher/server/database/models.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/models.py | BSD-3-Clause |
def session_has_read_access(cls, session, instance=None):
"""
Check that the authenticated *session* has access to read the
specified model *instance*.
:param session: The authenticated session to check access for.
:param instance: The optional model instance to inspect.
:return: Whether the session has th... |
Check that the authenticated *session* has access to read the
specified model *instance*.
:param session: The authenticated session to check access for.
:param instance: The optional model instance to inspect.
:return: Whether the session has the desired permissions.
:rtype: bool
| session_has_read_access | python | rsmusllp/king-phisher | king_phisher/server/database/models.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/models.py | BSD-3-Clause |
def session_has_read_prop_access(cls, session, prop, instance=None):
"""
Check that the authenticated *session* has access to read the property
of the specified model *instance*. This allows models to only explicitly
control which of their attributes can be read by a particular *session*.
:param session: The... |
Check that the authenticated *session* has access to read the property
of the specified model *instance*. This allows models to only explicitly
control which of their attributes can be read by a particular *session*.
:param session: The authenticated session to check access for.
:param instance: The optiona... | session_has_read_prop_access | python | rsmusllp/king-phisher | king_phisher/server/database/models.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/models.py | BSD-3-Clause |
def session_has_update_access(cls, session, instance=None):
"""
Check that the authenticated *session* has access to update the
specified model *instance*.
:param session: The authenticated session to check access for.
:param instance: The optional model instance to inspect.
:return: Whether the session ha... |
Check that the authenticated *session* has access to update the
specified model *instance*.
:param session: The authenticated session to check access for.
:param instance: The optional model instance to inspect.
:return: Whether the session has the desired permissions.
:rtype: bool
| session_has_update_access | python | rsmusllp/king-phisher | king_phisher/server/database/models.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/models.py | BSD-3-Clause |
def metatable(cls):
"""
Generate a :py:class:`.MetaTable` instance for this model class.
:return: The appropriate metadata for the table represented by this model.
:rtype: :py:class:`.MetaTable`
"""
columns = tuple(col.name for col in cls.__table__.columns)
return MetaTable(column_names=columns, model=cl... |
Generate a :py:class:`.MetaTable` instance for this model class.
:return: The appropriate metadata for the table represented by this model.
:rtype: :py:class:`.MetaTable`
| metatable | python | rsmusllp/king-phisher | king_phisher/server/database/models.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/models.py | BSD-3-Clause |
def __init__(self, namespace=None, order_by='created'):
"""
.. versionchanged:: 1.14.0
Added the *order_by* parameter.
:param str namespace: The unique identifier of this namespace.
:param str order_by: The attribute to order stored items by. This must be one of "created", "id", "key", or "modified".
"""
... |
.. versionchanged:: 1.14.0
Added the *order_by* parameter.
:param str namespace: The unique identifier of this namespace.
:param str order_by: The attribute to order stored items by. This must be one of "created", "id", "key", or "modified".
| __init__ | python | rsmusllp/king-phisher | king_phisher/server/database/storage.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/storage.py | BSD-3-Clause |
def validate_credential(credential, campaign):
"""
Validate a *credential* object with regards to the configuration provided in
*campaign*. This uses :py:func:`~.validate_credential_fields` to validate
each field individually and then return either ``None``, ``True`` or
``False``. If no validation took place on an... |
Validate a *credential* object with regards to the configuration provided in
*campaign*. This uses :py:func:`~.validate_credential_fields` to validate
each field individually and then return either ``None``, ``True`` or
``False``. If no validation took place on any field, ``None`` is returned,
otherwise if any fi... | validate_credential | python | rsmusllp/king-phisher | king_phisher/server/database/validation.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/validation.py | BSD-3-Clause |
def validate_credential_fields(credential, campaign):
"""
Validate a *credential* object with regards to the configuration provided in
*campaign*. Each field in the *credential* object is validated and a new
:py:class:`~.CredentialCollection` is returned with it's fields set to the
results of the validation. A fie... |
Validate a *credential* object with regards to the configuration provided in
*campaign*. Each field in the *credential* object is validated and a new
:py:class:`~.CredentialCollection` is returned with it's fields set to the
results of the validation. A fields validation results are either ``None``,
``True`` or `... | validate_credential_fields | python | rsmusllp/king-phisher | king_phisher/server/database/validation.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/database/validation.py | BSD-3-Clause |
def info_has_read_prop_access(cls, info, model, field_name=None, instance=None):
"""
Check that the context provided by *info* has access to read the
specified property of the model. This can be used to ensure that
sessions which can not read a protected field can also not obtain
indirect access such as filte... |
Check that the context provided by *info* has access to read the
specified property of the model. This can be used to ensure that
sessions which can not read a protected field can also not obtain
indirect access such as filtering or sorting by it.
:param info: The resolve information for this execution.
:... | info_has_read_prop_access | python | rsmusllp/king-phisher | king_phisher/server/graphql/middleware.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/graphql/middleware.py | BSD-3-Clause |
def sa_get_relationship(session, model, name):
"""
Resolve the relationship on a SQLAlchemy model to either an object (in the
case of one-to-one relationships) or a query to all of the objects (in the
case of one-to-many relationships).
:param session: The SQLAlchemy session to associate the query with.
:param m... |
Resolve the relationship on a SQLAlchemy model to either an object (in the
case of one-to-one relationships) or a query to all of the objects (in the
case of one-to-many relationships).
:param session: The SQLAlchemy session to associate the query with.
:param model: The SQLAlchemy model of the object associated... | sa_get_relationship | python | rsmusllp/king-phisher | king_phisher/server/graphql/types/database.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/graphql/types/database.py | BSD-3-Clause |
def sa_object_resolver(attname, default_value, model, info, **kwargs):
"""
Resolve the attribute for the given SQLAlchemy model object. If the
attribute is a relationship, use :py:func:`.sa_get_relationship` to resolve
it.
:param str attname: The name of the attribute to resolve on the object.
:param default_val... |
Resolve the attribute for the given SQLAlchemy model object. If the
attribute is a relationship, use :py:func:`.sa_get_relationship` to resolve
it.
:param str attname: The name of the attribute to resolve on the object.
:param default_value: The default value to return if the attribute is unavailable.
:param mo... | sa_object_resolver | python | rsmusllp/king-phisher | king_phisher/server/graphql/types/database.py | https://github.com/rsmusllp/king-phisher/blob/master/king_phisher/server/graphql/types/database.py | BSD-3-Clause |
def prepare_latents(
self,
batch_size: int, # Number of videos to generate in parallel
num_channels_latents: int, # Number of channels in the latents
width: int, # Width of the video frame
height: int, ... |
Prepares the initial latents for video generation.
Args:
batch_size (int): Number of videos to generate in parallel.
num_channels_latents (int): Number of channels in the latents.
width (int): Width of the video frame.
height (int): Height of the video f... | prepare_latents | python | fudan-generative-vision/hallo | hallo/animate/face_animate.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/animate/face_animate.py | MIT |
def decode_latents(self, latents):
"""
Decode the latents to produce a video.
Parameters:
latents (torch.Tensor): The latents to be decoded.
Returns:
video (torch.Tensor): The decoded video.
video_length (int): The length of the video in frames.
"""
... |
Decode the latents to produce a video.
Parameters:
latents (torch.Tensor): The latents to be decoded.
Returns:
video (torch.Tensor): The decoded video.
video_length (int): The length of the video in frames.
| decode_latents | python | fudan-generative-vision/hallo | hallo/animate/face_animate.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/animate/face_animate.py | MIT |
def enable_sequential_cpu_offload(self, gpu_id=0):
"""
Offloads selected models to the GPU for increased performance.
Args:
gpu_id (int, optional): The ID of the GPU to offload models to. Defaults to 0.
"""
device = torch.device(f"cuda:{gpu_id}")
for cpu_off... |
Offloads selected models to the GPU for increased performance.
Args:
gpu_id (int, optional): The ID of the GPU to offload models to. Defaults to 0.
| enable_sequential_cpu_offload | python | fudan-generative-vision/hallo | hallo/animate/face_animate_static.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/animate/face_animate_static.py | MIT |
def decode_latents(self, latents):
"""
Decode the given latents to video frames.
Parameters:
latents (torch.Tensor): The latents to be decoded. Shape: (batch_size, num_channels_latents, video_length, height, width).
Returns:
video (torch.Tensor): The decoded video frame... |
Decode the given latents to video frames.
Parameters:
latents (torch.Tensor): The latents to be decoded. Shape: (batch_size, num_channels_latents, video_length, height, width).
Returns:
video (torch.Tensor): The decoded video frames. Shape: (batch_size, num_channels_latents, v... | decode_latents | python | fudan-generative-vision/hallo | hallo/animate/face_animate_static.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/animate/face_animate_static.py | MIT |
def prepare_latents(
self,
batch_size,
num_channels_latents,
width,
height,
dtype,
device,
generator,
latents=None,
):
"""
Prepares the initial latents for the diffusion pipeline.
Args:
batch_size (int): The... |
Prepares the initial latents for the diffusion pipeline.
Args:
batch_size (int): The number of images to generate in one forward pass.
num_channels_latents (int): The number of channels in the latents tensor.
width (int): The width of the latents tensor.
... | prepare_latents | python | fudan-generative-vision/hallo | hallo/animate/face_animate_static.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/animate/face_animate_static.py | MIT |
def prepare_condition(
self,
cond_image,
width,
height,
device,
dtype,
do_classififer_free_guidance=False,
):
"""
Prepares the condition for the face animation pipeline.
Args:
cond_image (torch.Tensor): The conditional imag... |
Prepares the condition for the face animation pipeline.
Args:
cond_image (torch.Tensor): The conditional image tensor.
width (int): The width of the output image.
height (int): The height of the output image.
device (torch.device): The device to run the ... | prepare_condition | python | fudan-generative-vision/hallo | hallo/animate/face_animate_static.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/animate/face_animate_static.py | MIT |
def preprocess(self, wav_file: str, clip_length: int=-1):
"""
Preprocess a WAV audio file by separating the vocals from the background and resampling it to a 16 kHz sample rate.
The separated vocal track is then converted into wav2vec2 for further processing or analysis.
Args:
... |
Preprocess a WAV audio file by separating the vocals from the background and resampling it to a 16 kHz sample rate.
The separated vocal track is then converted into wav2vec2 for further processing or analysis.
Args:
wav_file (str): The path to the WAV file to be processed. This fil... | preprocess | python | fudan-generative-vision/hallo | hallo/datasets/audio_processor.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/datasets/audio_processor.py | MIT |
def get_embedding(self, wav_file: str):
"""preprocess wav audio file convert to embeddings
Args:
wav_file (str): The path to the WAV file to be processed. This file should be accessible and in WAV format.
Returns:
torch.tensor: Returns an audio embedding as a torch.tens... | preprocess wav audio file convert to embeddings
Args:
wav_file (str): The path to the WAV file to be processed. This file should be accessible and in WAV format.
Returns:
torch.tensor: Returns an audio embedding as a torch.tensor
| get_embedding | python | fudan-generative-vision/hallo | hallo/datasets/audio_processor.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/datasets/audio_processor.py | MIT |
def preprocess(self, source_image_path: str, cache_dir: str, face_region_ratio: float):
"""
Apply preprocessing to the source image to prepare for face analysis.
Parameters:
source_image_path (str): The path to the source image.
cache_dir (str): The directory to cache in... |
Apply preprocessing to the source image to prepare for face analysis.
Parameters:
source_image_path (str): The path to the source image.
cache_dir (str): The directory to cache intermediate results.
Returns:
None
| preprocess | python | fudan-generative-vision/hallo | hallo/datasets/image_processor.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/datasets/image_processor.py | MIT |
def close(self):
"""
Closes the ImageProcessor and releases any resources held by the FaceAnalysis instance.
Args:
self: The ImageProcessor instance.
Returns:
None.
"""
for _, model in self.face_analysis.models.items():
if hasattr(mod... |
Closes the ImageProcessor and releases any resources held by the FaceAnalysis instance.
Args:
self: The ImageProcessor instance.
Returns:
None.
| close | python | fudan-generative-vision/hallo | hallo/datasets/image_processor.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/datasets/image_processor.py | MIT |
def preprocess(self, source_image_path: str):
"""
Apply preprocessing to the source image to prepare for face analysis.
Parameters:
source_image_path (str): The path to the source image.
cache_dir (str): The directory to cache intermediate results.
Returns:
... |
Apply preprocessing to the source image to prepare for face analysis.
Parameters:
source_image_path (str): The path to the source image.
cache_dir (str): The directory to cache intermediate results.
Returns:
None
| preprocess | python | fudan-generative-vision/hallo | hallo/datasets/image_processor.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/datasets/image_processor.py | MIT |
def close(self):
"""
Closes the ImageProcessor and releases any resources held by the FaceAnalysis instance.
Args:
self: The ImageProcessor instance.
Returns:
None.
"""
for _, model in self.face_analysis.models.items():
if hasattr(mod... |
Closes the ImageProcessor and releases any resources held by the FaceAnalysis instance.
Args:
self: The ImageProcessor instance.
Returns:
None.
| close | python | fudan-generative-vision/hallo | hallo/datasets/image_processor.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/datasets/image_processor.py | MIT |
def augmentation(self, image, transform, state=None):
"""
Apply data augmentation to the input image.
Args:
image (PIL.Image): The input image.
transform (torchvision.transforms.Compose): The data augmentation transforms.
state (dict, optional): The random st... |
Apply data augmentation to the input image.
Args:
image (PIL.Image): The input image.
transform (torchvision.transforms.Compose): The data augmentation transforms.
state (dict, optional): The random state for reproducibility. Defaults to None.
Returns:
... | augmentation | python | fudan-generative-vision/hallo | hallo/datasets/mask_image.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/datasets/mask_image.py | MIT |
def augmentation(self, images, transform, state=None):
"""
Apply the given transformation to the input images.
Args:
images (List[PIL.Image] or PIL.Image): The input images to be transformed.
transform (torchvision.transforms.Compose): The transformation to be ap... |
Apply the given transformation to the input images.
Args:
images (List[PIL.Image] or PIL.Image): The input images to be transformed.
transform (torchvision.transforms.Compose): The transformation to be applied to the images.
state (torch.ByteTensor, optional... | augmentation | python | fudan-generative-vision/hallo | hallo/datasets/talk_video.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/datasets/talk_video.py | MIT |
def forward(self, x: torch.Tensor, objs: torch.Tensor) -> torch.Tensor:
"""
Apply the Gated Self-Attention mechanism to the input tensor `x` and object tensor `objs`.
Args:
x (torch.Tensor): The input tensor.
objs (torch.Tensor): The object tensor.
Returns:
... |
Apply the Gated Self-Attention mechanism to the input tensor `x` and object tensor `objs`.
Args:
x (torch.Tensor): The input tensor.
objs (torch.Tensor): The object tensor.
Returns:
torch.Tensor: The output tensor after applying Gated Self-Attention.
... | forward | python | fudan-generative-vision/hallo | hallo/models/attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/attention.py | MIT |
def set_chunk_feed_forward(self, chunk_size: Optional[int], dim: int = 0):
"""
Sets the chunk size for feed-forward processing in the transformer block.
Args:
chunk_size (Optional[int]): The size of the chunks to process in feed-forward layers.
If None, the chunk size i... |
Sets the chunk size for feed-forward processing in the transformer block.
Args:
chunk_size (Optional[int]): The size of the chunks to process in feed-forward layers.
If None, the chunk size is set to the maximum possible value.
dim (int, optional): The dimension al... | set_chunk_feed_forward | python | fudan-generative-vision/hallo | hallo/models/attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/attention.py | MIT |
def forward(
self,
hidden_states: torch.FloatTensor,
attention_mask: Optional[torch.FloatTensor] = None,
encoder_hidden_states: Optional[torch.FloatTensor] = None,
encoder_attention_mask: Optional[torch.FloatTensor] = None,
timestep: Optional[torch.LongTensor] = None,
... |
This function defines the forward pass of the BasicTransformerBlock.
Args:
self (BasicTransformerBlock):
An instance of the BasicTransformerBlock class.
hidden_states (torch.FloatTensor):
A tensor containing the hidden states.
attenti... | forward | python | fudan-generative-vision/hallo | hallo/models/attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/attention.py | MIT |
def __init__(
self,
dim: int,
num_attention_heads: int,
attention_head_dim: int,
dropout=0.0,
cross_attention_dim: Optional[int] = None,
activation_fn: str = "geglu",
num_embeds_ada_norm: Optional[int] = None,
attention_bias: bool = False,
... |
The TemporalBasicTransformerBlock class is a PyTorch module that extends the BasicTransformerBlock to include temporal attention mechanisms.
This is particularly useful for video-related tasks, where the model needs to capture the temporal information within the sequence of frames.
The block ... | __init__ | python | fudan-generative-vision/hallo | hallo/models/attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/attention.py | MIT |
def forward(
self,
hidden_states,
encoder_hidden_states=None,
timestep=None,
attention_mask=None,
video_length=None,
):
"""
Forward pass for the TemporalBasicTransformerBlock.
Args:
hidden_states (torch.FloatTensor): The input hidd... |
Forward pass for the TemporalBasicTransformerBlock.
Args:
hidden_states (torch.FloatTensor): The input hidden states with shape (batch_size, seq_len, dim).
encoder_hidden_states (torch.FloatTensor, optional): The encoder hidden states with shape (batch_size, src_seq_len, dim).
... | forward | python | fudan-generative-vision/hallo | hallo/models/attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/attention.py | MIT |
def __init__(
self,
dim: int,
num_attention_heads: int,
attention_head_dim: int,
dropout=0.0,
cross_attention_dim: Optional[int] = None,
activation_fn: str = "geglu",
num_embeds_ada_norm: Optional[int] = None,
attention_bias: bool = False,
... |
Initializes the AudioTemporalBasicTransformerBlock module.
Args:
dim (int): The dimension of the input and output embeddings.
num_attention_heads (int): The number of attention heads in the multi-head self-attention mechanism.
attention_head_dim (int): The dimension of... | __init__ | python | fudan-generative-vision/hallo | hallo/models/attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/attention.py | MIT |
def forward(
self,
hidden_states,
encoder_hidden_states=None,
timestep=None,
attention_mask=None,
full_mask=None,
face_mask=None,
lip_mask=None,
motion_scale=None,
video_length=None,
):
"""
Forward pass for the AudioTemp... |
Forward pass for the AudioTemporalBasicTransformerBlock.
Args:
hidden_states (torch.FloatTensor): The input hidden states.
encoder_hidden_states (torch.FloatTensor, optional): The encoder hidden states. Defaults to None.
timestep (torch.LongTensor, optional): The ti... | forward | python | fudan-generative-vision/hallo | hallo/models/attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/attention.py | MIT |
def zero_module(module):
"""
Zeroes out the parameters of a given module.
Args:
module (nn.Module): The module whose parameters need to be zeroed out.
Returns:
None.
"""
for p in module.parameters():
nn.init.zeros_(p)
return module |
Zeroes out the parameters of a given module.
Args:
module (nn.Module): The module whose parameters need to be zeroed out.
Returns:
None.
| zero_module | python | fudan-generative-vision/hallo | hallo/models/attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/attention.py | MIT |
def forward(self, audio_embeds):
"""
Defines the forward pass for the AudioProjModel.
Parameters:
audio_embeds (torch.Tensor): The input audio embeddings with shape (batch_size, video_length, blocks, channels).
Returns:
context_tokens (torch.Tensor): The output ... |
Defines the forward pass for the AudioProjModel.
Parameters:
audio_embeds (torch.Tensor): The input audio embeddings with shape (batch_size, video_length, blocks, channels).
Returns:
context_tokens (torch.Tensor): The output context tokens with shape (batch_size, video... | forward | python | fudan-generative-vision/hallo | hallo/models/audio_proj.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/audio_proj.py | MIT |
def forward(self, conditioning):
"""
Forward pass of the FaceLocator model.
Args:
conditioning (Tensor): The input conditioning tensor.
Returns:
Tensor: The output embedding tensor.
"""
embedding = self.conv_in(conditioning)
embedding = F... |
Forward pass of the FaceLocator model.
Args:
conditioning (Tensor): The input conditioning tensor.
Returns:
Tensor: The output embedding tensor.
| forward | python | fudan-generative-vision/hallo | hallo/models/face_locator.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/face_locator.py | MIT |
def forward(self, image_embeds):
"""
Forward pass of the ImageProjModel, which takes in image embeddings and returns the
projected tokens after reshaping and normalization.
Args:
image_embeds (torch.Tensor): The input image embeddings, with shape
batch_size x num... |
Forward pass of the ImageProjModel, which takes in image embeddings and returns the
projected tokens after reshaping and normalization.
Args:
image_embeds (torch.Tensor): The input image embeddings, with shape
batch_size x num_image_tokens x clip_embeddings_dim.
... | forward | python | fudan-generative-vision/hallo | hallo/models/image_proj.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/image_proj.py | MIT |
def zero_module(module):
"""
Zero out the parameters of a module and return it.
Args:
- module: A PyTorch module to zero out its parameters.
Returns:
A zeroed out PyTorch module.
"""
for p in module.parameters():
p.detach().zero_()
return module |
Zero out the parameters of a module and return it.
Args:
- module: A PyTorch module to zero out its parameters.
Returns:
A zeroed out PyTorch module.
| zero_module | python | fudan-generative-vision/hallo | hallo/models/motion_module.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/motion_module.py | MIT |
def get_motion_module(in_channels, motion_module_type: str, motion_module_kwargs: dict):
"""
This function returns a motion module based on the given type and parameters.
Args:
- in_channels (int): The number of input channels for the motion module.
- motion_module_type (str): The type of motio... |
This function returns a motion module based on the given type and parameters.
Args:
- in_channels (int): The number of input channels for the motion module.
- motion_module_type (str): The type of motion module to create. Currently, only "Vanilla" is supported.
- motion_module_kwargs (dict): A... | get_motion_module | python | fudan-generative-vision/hallo | hallo/models/motion_module.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/motion_module.py | MIT |
def forward(
self,
input_tensor,
encoder_hidden_states,
attention_mask=None,
):
"""
Forward pass of the TemporalTransformer3DModel.
Args:
hidden_states (torch.Tensor): The hidden states of the model.
encoder_hidden_states (torch.Tensor... |
Forward pass of the TemporalTransformer3DModel.
Args:
hidden_states (torch.Tensor): The hidden states of the model.
encoder_hidden_states (torch.Tensor, optional): The hidden states of the encoder.
attention_mask (torch.Tensor, optional): The attention mask.
... | forward | python | fudan-generative-vision/hallo | hallo/models/motion_module.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/motion_module.py | MIT |
def forward(self, hidden_states, encoder_hidden_states=None):
"""
Forward pass for the TemporalTransformer3DModel.
Args:
hidden_states (torch.Tensor): The input hidden states with shape (batch_size, sequence_length, in_channels).
encoder_hidden_states (torch.Tensor, opti... |
Forward pass for the TemporalTransformer3DModel.
Args:
hidden_states (torch.Tensor): The input hidden states with shape (batch_size, sequence_length, in_channels).
encoder_hidden_states (torch.Tensor, optional): The encoder hidden states with shape (batch_size, encoder_sequence... | forward | python | fudan-generative-vision/hallo | hallo/models/motion_module.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/motion_module.py | MIT |
def forward(
self,
hidden_states,
encoder_hidden_states=None,
video_length=None,
):
"""
Forward pass for the TemporalTransformerBlock.
Args:
hidden_states (torch.Tensor): The input hidden states with shape
(batch_size, video_length... |
Forward pass for the TemporalTransformerBlock.
Args:
hidden_states (torch.Tensor): The input hidden states with shape
(batch_size, video_length, in_channels).
encoder_hidden_states (torch.Tensor, optional): The encoder hidden states
with shape (b... | forward | python | fudan-generative-vision/hallo | hallo/models/motion_module.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/motion_module.py | MIT |
def set_use_memory_efficient_attention_xformers(
self,
use_memory_efficient_attention_xformers: bool,
attention_op = None,
):
"""
Sets the use of memory-efficient attention xformers for the VersatileAttention class.
Args:
use_memory_efficient_attention_xf... |
Sets the use of memory-efficient attention xformers for the VersatileAttention class.
Args:
use_memory_efficient_attention_xformers (bool): A boolean flag indicating whether to use memory-efficient attention xformers or not.
Returns:
None
| set_use_memory_efficient_attention_xformers | python | fudan-generative-vision/hallo | hallo/models/motion_module.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/motion_module.py | MIT |
def forward(
self,
hidden_states,
encoder_hidden_states=None,
attention_mask=None,
video_length=None,
**cross_attention_kwargs,
):
"""
Args:
hidden_states (`torch.Tensor`):
The hidden states to be passed through the model.
... |
Args:
hidden_states (`torch.Tensor`):
The hidden states to be passed through the model.
encoder_hidden_states (`torch.Tensor`, optional):
The encoder hidden states to be passed through the model.
attention_mask (`torch.Tensor`, optional):
... | forward | python | fudan-generative-vision/hallo | hallo/models/motion_module.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/motion_module.py | MIT |
def torch_dfs(model: torch.nn.Module):
"""
Perform a depth-first search (DFS) traversal on a PyTorch model's neural network architecture.
This function recursively traverses all the children modules of a given PyTorch model and returns a list
containing all the modules in the model's architecture. The ... |
Perform a depth-first search (DFS) traversal on a PyTorch model's neural network architecture.
This function recursively traverses all the children modules of a given PyTorch model and returns a list
containing all the modules in the model's architecture. The DFS approach starts with the input model and
... | torch_dfs | python | fudan-generative-vision/hallo | hallo/models/mutual_self_attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/mutual_self_attention.py | MIT |
def __init__(
self,
unet,
mode="write",
do_classifier_free_guidance=False,
attention_auto_machine_weight=float("inf"),
gn_auto_machine_weight=1.0,
style_fidelity=1.0,
reference_attn=True,
reference_adain=False,
fusion_blocks="midup",
... |
Initializes the ReferenceAttentionControl class.
Args:
unet (torch.nn.Module): The UNet model.
mode (str, optional): The mode of operation. Defaults to "write".
do_classifier_free_guidance (bool, optional): Whether to do classifier-free guidance. Defaults to False.
... | __init__ | python | fudan-generative-vision/hallo | hallo/models/mutual_self_attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/mutual_self_attention.py | MIT |
def update(self, writer, dtype=torch.float16):
"""
Update the model's parameters.
Args:
writer (torch.nn.Module): The model's writer object.
dtype (torch.dtype, optional): The data type to be used for the update. Defaults to torch.float16.
Returns:
N... |
Update the model's parameters.
Args:
writer (torch.nn.Module): The model's writer object.
dtype (torch.dtype, optional): The data type to be used for the update. Defaults to torch.float16.
Returns:
None.
| update | python | fudan-generative-vision/hallo | hallo/models/mutual_self_attention.py | https://github.com/fudan-generative-vision/hallo/blob/master/hallo/models/mutual_self_attention.py | MIT |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves Python code examples from Django repository that contain 'django' in the code, which helps identify Django-specific code snippets but provides limited analytical insights beyond basic filtering.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.