_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q244300
TcExProfile.load_profiles
train
def load_profiles(self): """Return configuration data. Load on first access, otherwise return existing data. .. code-block:: python self.profiles = { <profile name>: { 'data': {}, 'ij_filename': <filename>, ...
python
{ "resource": "" }
q244301
TcExProfile.load_profiles_from_file
train
def load_profiles_from_file(self, fqfn): """Load profiles from file. Args: fqfn (str): Fully qualified file name. """ if self.args.verbose: print('Loading profiles from File: {}{}{}'.format(c.Style.BRIGHT, c.Fore.MAGENTA, fqfn)) with open(fqfn, 'r+') as f...
python
{ "resource": "" }
q244302
TcExProfile.print_permutations
train
def print_permutations(self): """Print all valid permutations.""" index = 0 permutations = [] for p in self._input_permutations:
python
{ "resource": "" }
q244303
TcExProfile.profile_create
train
def profile_create(self): """Create a profile.""" if self.args.profile_name in self.profiles: self.handle_error('Profile "{}" already exists.'.format(self.args.profile_name)) # load the install.json file defined as a arg (default: install.json) ij = self.load_install_json(se...
python
{ "resource": "" }
q244304
TcExProfile.profile_delete
train
def profile_delete(self): """Delete an existing profile.""" self.validate_profile_exists() profile_data = self.profiles.get(self.args.profile_name) fqfn = profile_data.get('fqfn') with open(fqfn, 'r+') as fh: data = json.load(fh) for profile in data: ...
python
{ "resource": "" }
q244305
TcExProfile.profile_settings_args
train
def profile_settings_args(self, ij, required): """Return args based on install.json or layout.json params. Args: ij (dict): The install.json contents. required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or opti...
python
{ "resource": "" }
q244306
TcExProfile.profile_settings_args_install_json
train
def profile_settings_args_install_json(self, ij, required): """Return args based on install.json params. Args: ij (dict): The install.json contents. required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or option...
python
{ "resource": "" }
q244307
TcExProfile.profile_settings_args_layout_json
train
def profile_settings_args_layout_json(self, required): """Return args based on layout.json and conditional rendering. Args: required (bool): If True only required args will be returned. Returns: dict: Dictionary of required or optional App args. """ pro...
python
{ "resource": "" }
q244308
TcExProfile.profile_setting_default_args
train
def profile_setting_default_args(ij): """Build the default args for this profile. Args: ij (dict): The install.json contents. Returns: dict: The default args for a Job or Playbook App. """ # build default args profile_default_args = OrderedDict(...
python
{ "resource": "" }
q244309
TcExProfile.profile_settings_validations
train
def profile_settings_validations(self): """Create 2 default validations rules for each output variable. * One validation rule to check that the output variable is not null. * One validation rule to ensure the output value is of the correct type. """ ij = self.load_install_json(...
python
{ "resource": "" }
q244310
TcExProfile.profile_update
train
def profile_update(self, profile): """Update an existing profile with new parameters or remove deprecated parameters. Args: profile (dict): The dictionary containting the profile settings. """ # warn about missing install_json parameter if profile.get('install_json')...
python
{ "resource": "" }
q244311
TcExProfile.profile_update_args_v2
train
def profile_update_args_v2(self, profile): """Update v1 profile args to v2 schema for args. .. code-block:: javascript "args": { "app": { "input_strings": "capitalize", "tc_action": "Capitalize" } }, ...
python
{ "resource": "" }
q244312
TcExProfile.profile_update_args_v3
train
def profile_update_args_v3(self, profile): """Update v1 profile args to v3 schema for args. .. code-block:: javascript "args": { "app": { "required": { "input_strings": "capitalize", "tc_action": "Capitaliz...
python
{ "resource": "" }
q244313
TcExProfile.profile_update_schema
train
def profile_update_schema(profile): """Update profile to latest schema. Args: profile (dict): The dictionary containting the profile settings. """ # add new "autoclear" field if profile.get('autoclear') is None: print( '{}{}Profile Update...
python
{ "resource": "" }
q244314
TcExProfile.profile_write
train
def profile_write(self, profile, outfile=None): """Write the profile to the output directory. Args: profile (dict): The dictionary containting the profile settings. outfile (str, optional): Defaults to None. The filename for the profile. """ # fully qualified ou...
python
{ "resource": "" }
q244315
TcExProfile.replace_validation
train
def replace_validation(self): """Replace the validation configuration in the selected profile. TODO: Update this method. """ self.validate_profile_exists() profile_data = self.profiles.get(self.args.profile_name) # check redis # if redis is None: # ...
python
{ "resource": "" }
q244316
TcExProfile.validate
train
def validate(self, profile): """Check to see if any args are "missing" from profile. Validate all args from install.json are in the profile. This can be helpful to validate that any new args added to App are included in the profiles. .. Note:: This method does not work with layout.jso...
python
{ "resource": "" }
q244317
TcExProfile.validate_layout_display
train
def validate_layout_display(self, table, display_condition): """Check to see if the display condition passes. Args: table (str): The name of the DB table which hold the App data. display_condition (str): The "where" clause of the DB SQL statement. Returns: b...
python
{ "resource": "" }
q244318
TcExProfile.validate_profile_exists
train
def validate_profile_exists(self): """Validate the provided profiles name exists.""" if self.args.profile_name not in self.profiles:
python
{ "resource": "" }
q244319
DataFilter._build_indexes
train
def _build_indexes(self): """Build indexes from data for fast filtering of data. Building indexes of data when possible. This is only supported when dealing with a List of Dictionaries with String values. """ if isinstance(self._data, list): for d in self._data: ...
python
{ "resource": "" }
q244320
DataFilter._starts_with
train
def _starts_with(field, filter_value): """Validate field starts with provided value. Args: filter_value (string): A string or list of values. Returns: (boolean): Results of validation
python
{ "resource": "" }
q244321
DataFilter.filter_data
train
def filter_data(self, field, filter_value, filter_operator, field_converter=None): """Filter the data given the provided. Args: field (string): The field to filter on. filter_value (string | list): The value to match. filter_operator (string): The operator for compar...
python
{ "resource": "" }
q244322
DataFilter.operator
train
def operator(self): """Supported Filter Operators + EQ - Equal To + NE - Not Equal To + GT - Greater Than + GE - Greater Than or Equal To + LT - Less Than + LE - Less Than or Equal To + SW - Starts With + IN - In String or Array + NI - Not...
python
{ "resource": "" }
q244323
Tag.groups
train
def groups(self, group_type=None, filters=None, params=None): """ Gets all groups from a tag. Args: filters: params: group_type: """
python
{ "resource": "" }
q244324
Tag.indicators
train
def indicators(self, indicator_type=None, filters=None, params=None): """ Gets all indicators from a tag. Args: params: filters: indicator_type: """ indicator = self._tcex.ti.indicator(indicator_type)
python
{ "resource": "" }
q244325
Tag.victims
train
def victims(self, filters=None, params=None): """ Gets all victims from a tag. """ victim = self._tcex.ti.victim(None) for v in self.tc_requests.victims_from_tag(
python
{ "resource": "" }
q244326
TcExAuth._logger
train
def _logger(): """Initialize basic stream logger.""" logger = logging.getLogger(__name__)
python
{ "resource": "" }
q244327
TcExTokenAuth._renew_token
train
def _renew_token(self, retry=True): """Renew expired ThreatConnect Token.""" self.renewing = True self.log.info('Renewing ThreatConnect Token') self.log.info('Current Token Expiration: {}'.format(self._token_expiration)) try: params = {'expiredToken': self._token} ...
python
{ "resource": "" }
q244328
TcExArgParser._api_arguments
train
def _api_arguments(self): """Argument specific to working with TC API. --tc_token token Token provided by ThreatConnect for app Authorization. --tc_token_expires token_expires Expiration time for the passed Token. --api_access_id access_id Access ID used for HM...
python
{ "resource": "" }
q244329
TcExArgParser._batch_arguments
train
def _batch_arguments(self): """Arguments specific to Batch API writes. --batch_action action Action for the batch job ['Create', 'Delete']. --batch_chunk number The maximum number of indicator per batch job. --batch_halt_on_error Flag to indicate that the bat...
python
{ "resource": "" }
q244330
TcExArgParser._playbook_arguments
train
def _playbook_arguments(self): """Argument specific to playbook apps. These arguments will be passed to every playbook app by default. --tc_playbook_db_type type The DB type (currently on Redis is supported). --tc_playbook_db_context context The playbook context provided by TC....
python
{ "resource": "" }
q244331
TcExArgParser._standard_arguments
train
def _standard_arguments(self): """These are the standard args passed to every TcEx App. --api_default_org org The TC API user default organization. --tc_api_path path The TC API path (e.g https://api.threatconnect.com). --tc_in_path path The app in path. ...
python
{ "resource": "" }
q244332
App.run
train
def run(self): """Run main App logic.""" self.batch = self.tcex.batch(self.args.tc_owner) # using tcex requests to get built-in features (e.g., proxy, logging, retries) request = self.tcex.request() with request.session as s: r = s.get(self.url) if r.ok...
python
{ "resource": "" }
q244333
JSS.get
train
def get(self, url_path): """GET a url, handle errors, and return an etree. In general, it is better to use a higher level interface for API requests, like the search methods on this class, or the JSSObjects themselves. Args: url_path: String API endpoint path to GET...
python
{ "resource": "" }
q244334
JSS.post
train
def post(self, obj_class, url_path, data): """POST an object to the JSS. For creating new objects only. The data argument is POSTed to the JSS, which, upon success, returns the complete XML for the new object. This data is used to get the ID of the new object, and, via the JSSOb...
python
{ "resource": "" }
q244335
JSS.put
train
def put(self, url_path, data): """Update an existing object on the JSS. In general, it is better to use a higher level interface for updating objects, namely, making changes to a JSSObject subclass and then using its save method. Args: url_path: String API endpoint ...
python
{ "resource": "" }
q244336
JSS.delete
train
def delete(self, url_path, data=None): """Delete an object from the JSS. In general, it is better to use a higher level interface for deleting objects, namely, using a JSSObject's delete method. Args: url_path: String API endpoint path to DEL, with ID (e.g. ...
python
{ "resource": "" }
q244337
JSS._docstring_parameter
train
def _docstring_parameter(obj_type, subset=False): # pylint: disable=no-self-argument """Decorator for adding _docstring to repetitive methods.""" docstring = ( "Flexibly search the JSS for objects of type {}.\n\n\tArgs:\n\t\t" "Data: Allows different types to conduct different ...
python
{ "resource": "" }
q244338
JSS.pickle_all
train
def pickle_all(self, path): """Back up entire JSS to a Python Pickle. For each object type, retrieve all objects, and then pickle the entire smorgasbord. This will almost certainly take a long time! Pickling is Python's method for serializing/deserializing Python object...
python
{ "resource": "" }
q244339
JSS.from_pickle
train
def from_pickle(cls, path): """Load all objects from pickle file and return as dict. The dict returned will have keys named the same as the JSSObject classes contained, and the values will be JSSObjectLists of all full objects of that class (for example, the equivalent of my_jss...
python
{ "resource": "" }
q244340
JSS.write_all
train
def write_all(self, path): """Back up entire JSS to XML file. For each object type, retrieve all objects, and then pickle the entire smorgasbord. This will almost certainly take a long time! Pickling is Python's method for serializing/deserializing Python objects. This ...
python
{ "resource": "" }
q244341
JSS.load_from_xml
train
def load_from_xml(self, path): """Load all objects from XML file and return as dict. The dict returned will have keys named the same as the JSSObject classes contained, and the values will be JSSObjectLists of all full objects of that class (for example, the equivalent of my_jss...
python
{ "resource": "" }
q244342
JSSObjectFactory.get_object
train
def get_object(self, obj_class, data=None, subset=None): """Return a subclassed JSSObject instance by querying for existing objects or posting a new object. Args: obj_class: The JSSObject subclass type to search for or create. data: The data parameter per...
python
{ "resource": "" }
q244343
JSSObjectFactory.get_list
train
def get_list(self, obj_class, data, subset): """Get a list of objects as JSSObjectList. Args: obj_class: The JSSObject subclass type to search for. data: None subset: Some objects support a subset for listing; namely Computer, with subset="basic". ...
python
{ "resource": "" }
q244344
JSSObjectFactory.get_individual_object
train
def get_individual_object(self, obj_class, data, subset): """Return a JSSObject of type obj_class searched for by data. Args: obj_class: The JSSObject subclass type to search for. data: The data parameter performs different operations depending on the type passed...
python
{ "resource": "" }
q244345
JSSObjectFactory._build_jss_object_list
train
def _build_jss_object_list(self, response, obj_class): """Build a JSSListData object from response.""" response_objects = [item for item in response if item is not None
python
{ "resource": "" }
q244346
convert_response_to_text
train
def convert_response_to_text(response): """Convert a JSS HTML response to plaintext.""" # Responses are sent as html. Split on the newlines and give us # the <p> text back. errorlines = response.text.encode("utf-8").split("\n") error = [] pattern = re.compile(r"<p.*>(.*)</p>")
python
{ "resource": "" }
q244347
error_handler
train
def error_handler(exception_cls, response): """Handle HTTP errors by formatting into strings.""" # Responses are sent as html. Split on the newlines and give us # the <p> text back. error = convert_response_to_text(response) exception = exception_cls("Response
python
{ "resource": "" }
q244348
loop_until_valid_response
train
def loop_until_valid_response(prompt): """Loop over entering input until it is a valid bool-ish response. Args: prompt: Text presented to user. Returns: The bool value equivalent of what was entered. """ responses = {"Y": True, "YES": True, "TRUE": True,
python
{ "resource": "" }
q244349
indent_xml
train
def indent_xml(elem, level=0, more_sibs=False): """Indent an xml element object to prepare for pretty printing. To avoid changing the contents of the original Element, it is recommended that a copy is made to send to this function. Args: elem: Element to indent. level: Int indent level...
python
{ "resource": "" }
q244350
element_repr
train
def element_repr(self): """Return a string with indented XML data. Used to replace the __repr__ method of Element. """ # deepcopy so we don't mess with the valid XML.
python
{ "resource": "" }
q244351
JSSObjectList.sort
train
def sort(self): """Sort list elements by ID."""
python
{ "resource": "" }
q244352
JSSObjectList.sort_by_name
train
def sort_by_name(self): """Sort list elements by name."""
python
{ "resource": "" }
q244353
JSSObjectList.retrieve_by_id
train
def retrieve_by_id(self, id_): """Return a JSSObject for the element with ID id_""" items_with_id = [item for item in self if item.id == int(id_)]
python
{ "resource": "" }
q244354
JSSObjectList.retrieve_all
train
def retrieve_all(self, subset=None): """Return a list of all JSSListData elements as full JSSObjects. This can take a long time given a large number of objects, and depending on the size of each object. Subsetting to only include the data you need can improve performance. Args:...
python
{ "resource": "" }
q244355
JSSObjectList.pickle
train
def pickle(self, path): """Write objects to python pickle. Pickling is Python's method for serializing/deserializing Python objects. This allows you to save a fully functional JSSObject to disk, and then load it later, without having to retrieve it from the JSS. This me...
python
{ "resource": "" }
q244356
readPlistFromString
train
def readPlistFromString(data): '''Read a plist data from a string. Return the root object.''' try: plistData = buffer(data) except TypeError, err: raise NSPropertyListSerializationException(err) dataObject, dummy_plistFormat, error = ( NSPropertyListSerialization. propert...
python
{ "resource": "" }
q244357
writePlist
train
def writePlist(dataObject, filepath): ''' Write 'rootObject' as a plist to filepath. ''' plistData, error = ( NSPropertyListSerialization. dataFromPropertyList_format_errorDescription_( dataObject, NSPropertyListXMLFormat_v1_0, None)) if
python
{ "resource": "" }
q244358
writePlistToString
train
def writePlistToString(rootObject): '''Return 'rootObject' as a plist-formatted string.''' plistData, error = ( NSPropertyListSerialization. dataFromPropertyList_format_errorDescription_( rootObject, NSPropertyListXMLFormat_v1_0, None)) if plistData is None: if error:
python
{ "resource": "" }
q244359
JSSObject._new
train
def _new(self, name, **kwargs): """Create a new JSSObject with name and "keys". Generate a default XML template for this object, based on the class attribute "keys". Args: name: String name of the object to use as the object's name property. kwar...
python
{ "resource": "" }
q244360
JSSObject._set_xml_from_keys
train
def _set_xml_from_keys(self, root, item, **kwargs): """Create SubElements of root with kwargs. Args: root: Element to add SubElements to. item: Tuple key/value pair from self.data_keys to add. kwargs: For each item in self.data_keys, if it has a ...
python
{ "resource": "" }
q244361
JSSObject.get_url
train
def get_url(cls, data): """Return the URL for a get request based on data type. Args: data: Accepts multiple types. Int: Generate URL to object with data ID. None: Get basic object GET URL (list). String/Unicode: Search for <data> with default...
python
{ "resource": "" }
q244362
JSSObject.url
train
def url(self): """Return the path subcomponent of the url to this object. For example: "/computers/id/451"
python
{ "resource": "" }
q244363
JSSObject.delete
train
def delete(self, data=None): """Delete this object from the JSS.""" if not self.can_delete: raise JSSMethodNotAllowedError(self.__class__.__name__) if data:
python
{ "resource": "" }
q244364
JSSObject.save
train
def save(self): """Update or create a new object on the JSS. If this object is not yet on the JSS, this method will create a new object with POST, otherwise, it will try to update the existing object with PUT. Data validation is up to the client; The JSS in most cases will ...
python
{ "resource": "" }
q244365
JSSObject._handle_location
train
def _handle_location(self, location): """Return an element located at location with flexible args. Args: location: String xpath to use in an Element.find search OR an Element (which is simply returned). Returns: The found Element. Raises: ...
python
{ "resource": "" }
q244366
JSSObject.set_bool
train
def set_bool(self, location, value): """Set a boolean value. Casper booleans in XML are string literals of "true" or "false". This method sets the text value of "location" to the correct string representation of a boolean. Args: location: Element or a string path ar...
python
{ "resource": "" }
q244367
JSSObject.add_object_to_path
train
def add_object_to_path(self, obj, location): """Add an object of type JSSContainerObject to location. This method determines the correct list representation of an object and adds it to "location". For example, add a Computer to a ComputerGroup. The ComputerGroup will not have a child ...
python
{ "resource": "" }
q244368
JSSObject.remove_object_from_list
train
def remove_object_from_list(self, obj, list_element): """Remove an object from a list element. Args: obj: Accepts JSSObjects, id's, and names list_element: Accepts an Element or a string path to that element """ list_element = self._handle_locatio...
python
{ "resource": "" }
q244369
JSSObject.from_file
train
def from_file(cls, jss, filename): """Create a new JSSObject from an external XML file. Args: jss: A JSS object. filename: String path to an XML file. """
python
{ "resource": "" }
q244370
JSSObject.from_string
train
def from_string(cls, jss, xml_string): """Creates a new JSSObject from an UTF-8 XML string. Args: jss: A JSS
python
{ "resource": "" }
q244371
JSSObject.to_file
train
def to_file(self, path): """Write object XML to path. Args: path: String file path to the file you wish to (over)write. Path will have ~ expanded prior to opening. """
python
{ "resource": "" }
q244372
JSSContainerObject.as_list_data
train
def as_list_data(self): """Return an Element to be used in a list. Most lists want an element with tag of list_type, and subelements of id and name. Returns: Element: list representation of object. """ element = ElementTree.Element(self.list_type)
python
{ "resource": "" }
q244373
JSSGroupObject.add_criterion
train
def add_criterion(self, name, priority, and_or, search_type, value): # pylint: disable=too-many-arguments """Add a search criteria object to a smart group. Args: name: String Criteria type name (e.g. "Application Title") priority: Int or Str number priority of criterion. ...
python
{ "resource": "" }
q244374
JSSGroupObject.is_smart
train
def is_smart(self, value): """Set group is_smart property to value. Args: value: Boolean. """ self.set_bool("is_smart", value) if value is True: if self.find("criteria") is None:
python
{ "resource": "" }
q244375
JSSGroupObject.add_device
train
def add_device(self, device, container): """Add a device to a group. Wraps JSSObject.add_object_to_path. Args: device: A JSSObject to add (as list data), to this object. location: Element or a string path argument to find() """
python
{ "resource": "" }
q244376
JSSGroupObject.has_member
train
def has_member(self, device_object): """Return bool whether group has a device as a member. Args: device_object (Computer or MobileDevice). Membership is determined by ID, as names can be shared amongst devices. """ if device_object.tag == "computer": ...
python
{ "resource": "" }
q244377
DistributionPoints.copy
train
def copy(self, filename, id_=-1, pre_callback=None, post_callback=None): """Copy a package or script to all repos. Determines appropriate location (for file shares) and type based on file extension. Args: filename: String path to the local file to copy. id_: Pac...
python
{ "resource": "" }
q244378
DistributionPoints.copy_pkg
train
def copy_pkg(self, filename, id_=-1): """Copy a pkg, dmg, or zip to all repositories. Args: filename: String path to the local file to copy. id_: Integer ID you wish to associate package with for a JDS or CDP only. Default is -1, which is used
python
{ "resource": "" }
q244379
DistributionPoints.copy_script
train
def copy_script(self, filename, id_=-1): """Copy a script to all repositories. Takes into account whether a JSS has been migrated. See the individual DistributionPoint types for more information. Args:
python
{ "resource": "" }
q244380
DistributionPoints.delete
train
def delete(self, filename): """Delete a file from all repositories which support it. Individual repositories will determine correct location to delete from (Scripts vs. Packages). This will not remove the corresponding Package or Script object from the JSS's database! ...
python
{ "resource": "" }
q244381
DistributionPoints.umount
train
def umount(self, forced=True): """Umount all mountable distribution points. Defaults to using forced method. """
python
{ "resource": "" }
q244382
DistributionPoints.exists
train
def exists(self, filename): """Report whether a file exists on all distribution points. Determines file type by extension. Args: filename: Filename you wish to check. (No
python
{ "resource": "" }
q244383
_get_user_input
train
def _get_user_input(prompt, key_name, parent, input_func=raw_input): """Prompt the user for a value, and assign it to key_name.""" val = input_func(prompt) ElementTree.SubElement(parent, "key").text = key_name if isinstance(val, bool):
python
{ "resource": "" }
q244384
_handle_dist_server
train
def _handle_dist_server(ds_type, repos_array): """Ask user for whether to use a type of dist server.""" if ds_type not in ("JDS", "CDP"): raise ValueError("Must be JDS or CDP") prompt = "Does your JSS use a %s? (Y|N): " % ds_type result = loop_until_valid_response(prompt) if result: ...
python
{ "resource": "" }
q244385
JSSPrefs.parse_plist
train
def parse_plist(self, preferences_file): """Try to reset preferences from preference_file.""" preferences_file = os.path.expanduser(preferences_file) # Try to open using FoundationPlist. If it's not available, # fall back to plistlib and hope it's not binary encoded. try: ...
python
{ "resource": "" }
q244386
JSSPrefs.configure
train
def configure(self): """Prompt user for config and write to plist Uses preferences_file argument from JSSPrefs.__init__ as path to write. """ root = ElementTree.Element("dict") print ("It seems like you do not have a preferences file configured. " "Please ...
python
{ "resource": "" }
q244387
JSSPrefs._handle_repos
train
def _handle_repos(self, root): """Handle repo configuration.""" ElementTree.SubElement(root, "key").text = "repos" repos_array = ElementTree.SubElement(root, "array") # Make a temporary jss object to try to pull repo information. jss_server = JSS(url=self.url, user=self.user, pa...
python
{ "resource": "" }
q244388
JSSPrefs._write_plist
train
def _write_plist(self, root): """Write plist file based on our generated tree.""" # prettify the XML indent_xml(root) tree = ElementTree.ElementTree(root) with open(self.preferences_file, "w") as prefs_file: prefs_file.write( "<?xml version=\"1.0\" en...
python
{ "resource": "" }
q244389
Casper.update
train
def update(self): """Request an updated set of data from casper.jxml.""" response = self.jss.session.post(self.url, data=self.auth) response_xml = ElementTree.fromstring(response.text.encode("utf_8")) # Remove previous data, if any, and
python
{ "resource": "" }
q244390
mount_share_at_path
train
def mount_share_at_path(share_path, mount_path): """Mounts a share at the specified path Args: share_path: String URL with all auth info to connect to file share. mount_path: Path to mount share on. Returns: The mount point or raises an error """ sh_url = CFURLCreateWithStr...
python
{ "resource": "" }
q244391
auto_mounter
train
def auto_mounter(original): """Decorator for automatically mounting, if needed.""" def mounter(*args):
python
{ "resource": "" }
q244392
FileRepository.copy_pkg
train
def copy_pkg(self, filename, _): """Copy a package to the repo's Package subdirectory. Args: filename: Path for file to copy. _: Ignored. Used for compatibility with JDS repos. """ basename = os.path.basename(filename)
python
{ "resource": "" }
q244393
FileRepository.copy_script
train
def copy_script(self, filename, id_=-1): """Copy a script to the repo's Script subdirectory. Scripts are copied as files to a path, or, on a "migrated" JSS, are POSTed to the JSS (pass an id if you wish to associate the script with an existing Script object). Args: ...
python
{ "resource": "" }
q244394
FileRepository._copy_script_migrated
train
def _copy_script_migrated(self, filename, id_=-1, file_type=SCRIPT_FILE_TYPE): """Upload a script to a migrated JSS's database. On a "migrated" JSS, scripts are POSTed to the JSS. Pass an id if you wish to associate the script with an existing Script object...
python
{ "resource": "" }
q244395
FileRepository.delete
train
def delete(self, filename): """Delete a file from the repository. This method will not delete a script from a migrated JSS. Please remove migrated scripts with jss.Script.delete. Args: filename: String filename only (i.e. no path) of file to delete. Will han...
python
{ "resource": "" }
q244396
FileRepository.exists
train
def exists(self, filename): """Report whether a file exists on the distribution point. Determines file type by extension. Args: filename: Filename you wish to check. (No path! e.g.: "AdobeFlashPlayer-14.0.0.176.pkg")
python
{ "resource": "" }
q244397
MountedRepository.mount
train
def mount(self): """Mount the repository.""" if not self.is_mounted(): # OS X mounting is handled automagically in /Volumes: # DO NOT mkdir there! # For Linux, ensure the mountpoint exists. if not is_osx():
python
{ "resource": "" }
q244398
MountedRepository.umount
train
def umount(self, forced=True): """Try to unmount our mount point. Defaults to using forced method. If OS is Linux, it will not delete the mount point. Args: forced: Bool whether to force the unmount. Default is True. """ if self.is_mounted(): if ...
python
{ "resource": "" }
q244399
MountedRepository.is_mounted
train
def is_mounted(self): """Test for whether a mount point is mounted. If it is currently mounted, determine the path where it's mounted and update the connection's mount_point accordingly. """ mount_check = subprocess.check_output("mount").splitlines() # The mount command ...
python
{ "resource": "" }