Change perforce workspace view map from commandline - perforce

I have searched the internet and the perforce help pages, but couldn't find a solution to my problem.
In a script, so on the commandline, I want to change my workspace view map. For example:
//depot/some/branch/myfolder/mysubfolder/... /home/myuser/perforce/branch/myfolder/myworkspace/...
to
//depot/some/branch/... /home/myuser/perforce/branch/...
I cannot figure out what command to use. Can you help me out?

You'll need to use the p4 client command. You can script that using the -i and -o options, which let you interact with the workspace form via STDIN and STDOUT.
An easier path is using a scripting API like P4Python:
cspec = p4.fetch_client('my_ws_name')
view = ["//depot/some/branch/... /home/myuser/perforce/branch/..."]
cspec["View"] = view
p4.save_client(cspec)

Related

Perforce Skip File Download Based on Extension [duplicate]

I am using the command line tools of Perforce.
And with the p4 tool, I want to sync to a stream.
The problem is that I want to exclude a directory from my workspace.
If my work space was defined as a view, this would be possible with something like:
View:
//depot/Foo/... //Client/Foo/...
-//depot/Foo...bin/... //Client/Foo...bin/...
But the Stream: setting overrides the View: specification.
I have set the Stream using the command:
$ p4 client
I also looked into P4IGNORE mechanism, but this is of no use to my problem, as P4IGNORE will not influence the sync command.
I tried adding a Paths: command to my client spec, but that is not recognized in this context. I think it is used when specifying the stream, as done by the administrator of the depot?
This is exactly what virtual streams are for. :) Create a child of the stream with type virtual, and exclude the directory from the virtual child stream (via either Paths or Ignore in the stream spec). This will generate you a client view that is the desired subset of the parent stream.
https://www.perforce.com/blog/virtual-streams-windows-big-projects

asciidoctor - offline user manual is nowhere to be found

Does anyone know where to get an offline version of the Asciidoctor's user manual: https://asciidoctor.org/docs/user-manual/
It is weird, how developers brag about Asciidoctor being able to export to PDF, HTML... But at the same time they fail to present a nice PDF document for offline use...
You can get the raw adoc source from: https://github.com/asciidoctor/asciidoctor.org/blob/master/docs/user-manual.adoc and convert it using asciidoctor.
Feel free to grab the result directly from:
https://sqli.dev/asciidoctor/user-manual.pdf (asciidoctor-pdf threw a few errors with this document, which I haven’t investigated, so some things may not show up as intended)
https://sqli.dev/asciidoctor/user-manual.html (this html will still fetch online resources for fonts, mathjax, etc.)
You can use the following to limit the amount of online resources needed:
git clone https://github.com/asciidoctor/asciidoctor.org.git
cd asciidoctor.org/docs
curl -O https://fontawesome.com/v4.7.0/assets/font-awesome-4.7.0.zip
7z x font-awesome-4.7.0.zip
asciidoctor -a !iconfont-remote=# -a icons=font -a stylesdir=font-awesome-4.7.0/css -a !webfonts=# user-manual.adoc
The resulting user-manual.html will only try to fetch the MathJax.js from a remote site.
I would recommend to open an issue at https://github.com/asciidoctor/asciidoctor.org proposing that they offer offline download options.

Code Behind RStudio Server Export Function

I am currently using RStudio-server on Linux redhat. One nice feature of RStudio-server is that I can export from the server to my Windows desktop. Does anyone know the code behind the export drop-down?
The export function can be found via the Files tab:
(More >> Export...)
I would like use code to automate the exporting of objects. I figured I should be able to perform this export using the system function, but I am having trouble.
Thanks for any help.
I think this post might help you,
Spacedman explains that you can trigger the export by the use of the R function "browseURL", with the URL parameter replaced by the ftp path to the file.
If you absolutely want to trigger this export with a system command, perhaps you could create an R script taking as parameter the file to export and launch that script with the system() function =) Although I can't see clearly the advantages of such a process.
[edit] : After having tried it today, I realise my answer wasn't complete :
If you try the function browseURL on files such as "whateverRscript.r", it will display it in a tab of your browser, rather than trigger the download.
In order to actually make your browser download this kind of file, maybe you can zip it first.
To complete the automation process, just change the parameters of your browser such that it won't "ask everytimes where to stock the downloaded files"
This is what worked for me: run it on Server side. Working browser is required (I used Chrome)
my_data_file_name <- "data.RData"
# set file name
save(Data, file=my_data_file_name)
# save data to file
current_dir <- getwd()
# capture current working directory on server
my_export_file_path <- paste0(current_dir, '/', my_data_file_name)
# create a path for file to export
browseURL(my_export_file_path)
# export to local disk using browser's capabilities

saving to /home/user/Documents in different locales / languages

In my linux python app for Fedora I want to save user's work to /home/user/Documents/MyCoolApp/TheirGreatWork.txt
But I am not sure how to find the "Documents" folder if the user is not using English as their default language.
What is the right way to determine the right path so that files go in their "Documents" folder.
EDIT
Here is a which comes up if you change locales... showing how paths can get easily changed.
I'd use the subprocess module to get the output of the command xdg-user-dir DOCUMENTS. For example:
import subprocess
documents_dir = subprocess.check_output(["xdg-user-dir", "DOCUMENTS"])
print documents_dir # This is what you're looking for.
There is no right way as the user may have changed their locale, which (fortunately) does not rename the directory. If you want a fixed place for files managed by your app, use ~user/.MyCoolApp or let the user specify the directory.

Perforce "Locked client" error

I'm new to Perforce, and it is not going well at all. But currently, I am completely stuck, as all I can get it to say is:
$ p4 open a_code_file.cpp
Locked client 'my_hostname' can only be used by owner 'perforce'.
I have absolutely no idea what I did to upset it, and the error message itself is meaningless gibberish to me. "perforce" doesn't own anything - all the files are owned by me. I am in a Perforce repository, ie, there's a .p4rc a few directories up.
Edit: It only seems to be some files. If I:
$ cd some_other_directory_in_the_repo
$ p4 open a_file
... it works. So it's only some things...
The "locked client" error suggests that p4 is trying to use a client workspace, named after your hostname, owned by the user perforce. If Perforce can't find a valid client name, either in the registry (on Windows), environment variables, or in an environment file, it'll default to using a client workspace named after your hostname.
It sounds like Perforce can't find a valid client workspace for your "broken" directory, and finds one for your "working" directory.
Since you have one directory that works, and one directory that doesn't, can you try:
$ p4 set
from both directories, and compare the results? If Perforce can find a valid client, you'll see something like:
P4CLIENT=XXXX (config)
(the "(config)" means Perforce is getting that configuration variable from a configuration file. Consult p4 help set for more information on the various ways you can set variables.)
Look also for a line like:
P4CONFIG=.p4env
which is what Perforce will use to search for your workspace configuration. If you're using a file named .p4rc, that's what P4CONFIG should be set to.
I ran into this when I was distracted and forgot to export my P4CLIENT variable, i.e.:
P4CLIENT=XXXXX
Instead of:
export P4CLIENT=XXXXX

Resources