text stringlengths 0 828 |
|---|
"""""" get the filepath and filehandle to the rc file for the environment """""" |
rc_path = os.path.join(root_dir, '.rc') |
env_path = os.path.join(root_dir, '.env') |
fh = open(rc_path, ""w+"") |
# .rc will always source .env |
fh.write(source_template % (env_path, env_path)) |
return (rc_path, fh)" |
237,"def __get_gui_handle(self, root_dir): |
"""""" get the filepath and filehandle to the .env file for the environment """""" |
gui_path = os.path.join(root_dir, '.gui') |
fh = open(gui_path, ""w+"") |
return (gui_path, fh)" |
238,"def __symlink_dir(self, dir_name, name, path): |
"""""" |
Symlink an object at path to name in the dir_name folder. remove it if it already exists. |
"""""" |
target_dir = os.path.join(self.root_dir, dir_name) |
if not os.path.exists(target_dir): |
os.makedirs(target_dir) |
target_path = os.path.join(self.root_dir, dir_name, name) |
logger.debug(""Attempting to symlink %s to %s..."" % (path, target_path)) |
if os.path.exists(target_path): |
if os.path.islink(target_path): |
os.remove(target_path) |
else: |
logger.warn(""%s is not a symlink! please remove it manually."" % target_path) |
return |
os.symlink(path, target_path)" |
239,"def create(self, options=None): |
""""""Create a new document job (sync or async)."""""" |
if options is None: |
raise ValueError(""Please pass in an options dict"") |
if not _has_content(options): |
raise NoContentError(""must supply 'document_content' or 'document_url'"") |
default_options = { |
""name"": ""default"", |
""document_type"": ""pdf"", |
""test"": False, |
""async"": False, |
""raise_exception_on_failure"": False, |
} |
options = dict(list(default_options.items()) + list(options.items())) |
raise_exception_on_failure = options.pop(""raise_exception_on_failure"") |
query = {""user_credentials"": self.api_key} |
if options[""async""]: |
query[""output""] = ""json"" |
resp = requests.post( |
""%sdocs"" % (self._url), json=options, params=query, timeout=self._timeout |
) |
if raise_exception_on_failure and resp.status_code != 200: |
raise DocumentCreationFailure(resp.content, resp.status_code) |
if options[""async""]: |
return json.loads(resp.content.decode(""utf-8"")) |
else: |
return resp" |
240,"def list_docs(self, options=None): |
""""""Return list of previously created documents."""""" |
if options is None: |
raise ValueError(""Please pass in an options dict"") |
default_options = { |
""page"": 1, |
""per_page"": 100, |
""raise_exception_on_failure"": False, |
""user_credentials"": self.api_key, |
} |
options = dict(list(default_options.items()) + list(options.items())) |
raise_exception_on_failure = options.pop(""raise_exception_on_failure"") |
resp = requests.get( |
""%sdocs"" % (self._url), params=options, timeout=self._timeout |
) |
if raise_exception_on_failure and resp.status_code != 200: |
raise DocumentListingFailure(resp.content, resp.status_code) |
return resp" |
241,"def status(self, status_id, raise_exception_on_failure=False): |
""""""Return the status of the generation job."""""" |
query = {""output"": ""json"", ""user_credentials"": self.api_key} |
resp = requests.get( |
""%sstatus/%s"" % (self._url, status_id), params=query, timeout=self._timeout |
) |
if raise_exception_on_failure and resp.status_code != 200: |
raise DocumentStatusFailure(resp.content, resp.status_code) |
if resp.status_code == 200: |
as_json = json.loads(resp.content) |
if as_json[""status""] == ""completed"": |
as_json[""download_key""] = _get_download_key(as_json[""download_url""]) |
return as_json |
return resp" |
242,"def download(self, download_key, raise_exception_on_failure=False): |
""""""Download the file represented by the download_key."""""" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.