Hi, Luca.
IMAP would be better than POP I suppose.
- Log in to post comments
Hi, Luca.
IMAP would be better than POP I suppose.
Yes, I'm searching for a ready code downloading from Gmail etc. Or at least code connecting to the server.
ClassMethod GmailAsPOP3() As %Net.POP3
{
Set server=##class(%Net.POP3).%New()
Set server.port=995
//just in case we plan to fetch any messages
//that have attachments
Set server.StoreAttachToFile=1
Set server.StoreInlineToFile=1
Set server.AttachDir="c:\DOWNLOADS\"
Set servername="pop.gmail.com"
Set server.UseSTARTTLS=1
Set server.SSLConfiguration = "GMail" //any empty enabled client SSL/TLS config
Set user="mail@gmail.com"
Set pass="pass"
Set status=server.Connect(servername,user,pass)
If $$$ISERR(status)
{
Do $System.Status.DisplayError(status)
Quit $$$ERROR()
}
Quit server
}
It returns this error:ERROR #6013: Unable to make TCP/IP connection to mail server. An earlier connection may not have been closed. [zConnectPort+39^%Net.POP3.1:EMAIL]
That and DeepSee, yes.
Thanks
You can use script command for that
script --quiet myoutput.log csession cache work in terminal hang exit
If you want to log every command then you can enable it in SMP -> System Administration -> Security -> Auditing -> Configure System Events. Once there enable %System/%DirectMode/DirectMode event and every terminal command would be logged along with time and user who executed it. Audit must also be active, of course.
Please note, that another approach (put tstVar in the "public" list) suggested by Timothy Leavitt works better in most cases, as once defined a % variable can be modified anywhere within the process. With "public" list you retain full control over variable visibility which makes debugging much easier.
Some notes:
I'm against that. As it is right now, I can copy/paste code from <pre> tag into the terminal and it would work.
The advantage of <pre> block is that it would be displayed exactly as the author intended.
If we add line breaks the code would not work after copy/paste into the terminal.
Turns out FF renders the <pre> tag node with horisontal scrollbar (if required) and Chrome without. Ok.
Thank you Stefan!
Yes, I'm asking about persistent data, of course.
Learn -> Grous are missing.
Can't choose editor type now.
Since when removing working functionality became a good thing?
WYSWIG does not support some formatting when creating an article (break tag for example).
How do I get to groups list now?
"/" itself is also a valid REST path:
<Route Url="/" Method="GET" Call="Index"/>
What is the Criteria datatype?
Can you show the property definition?
If for example you have Criteria defined like this:
Property Criteria As %String(MAXLEN = 2000); // MAXLEN>512
Try to define the property like this:
Property Criteria As %String(COLLATION = "TRUNCATE(490)", MAXLEN = 2000);
How to debug SQL queries:
1. In SMP > System > Configuration > General SQL Settings enable the following flags (don't forget to press Save):
2. Purge all Cached Queries - execute in terminal (namespace with query):
3. Execute the query again to get an error
4. Open in studio %sqlcq.HSREGISTRY.cls966.1.int routine (it would be %sqlcq.HSREGISTRY.cls1.1.int after purge)
5. Go to %0AmEdun+4 in this routine and see what this is about. Set try/catch, and debug.
In this case the most likely scenario is that the code tries to set global subscript longer than the maximum of 511 characters. Since the only change between queries is the column (there is also "as Relevance" part in your error query, but I think it's irrelevant) then it's probably something with that.
Yes, DigitalOcean is quite good. I manage around 50 servers there and they don't disappoint. One issue I have is that they don't offer backup/snapshot management. All you can do with a backup is restore it to current or a new server. I'm used to features offered by other cloud providers, such as:
But to do it in DigitalOcean I need to create a new droplet from a backup (takes time and costs money) and browse it.
Also their in-browser-web-access is quite lacking - they offer only VNC access, but not:
We use several providers, on all of them there are servers for development & testing and production. Some features are availible on DO, some only in other places. Can't say I found a cloud provider offering everything I want in one place.
A lot of foss source samples to analyze are availible at our GitHub organizations:
Also thank you & forked.
These are not repositiories, but rather GitHub organisations with repositories. For example one of the repositories in intersistems-ru organisation is MDX2JSON, and there is a LICENSE file present with MIT licence right at the root. Most other projects are also licensed (check LICENSE file in the root folder of a repository).
Hello. You can do it like this:
Good way to calculate such property. One question I have is why you use indirection and $name function in the generated method? It can be safely removed, for example like this:
ClassMethod IsLastKnownRecordCheck(CitizenRef As %Integer, RelocationDate As %Date) As %Boolean [ CodeMode = objectgenerator ]
{
set storagename="Default"
set storageInd=%class.Storages.FindObjectId(%classname_"||"_storagename)
set storage=%class.Storages.GetAt(storageInd)
set indexLocation=storage.IndexLocation
do %code.WriteLine($c(9)_"quit $order("_indexLocation_"(""CitizenRelocation"", CitizenRef, RelocationDate))=""""")
quit $$$OK
}It can be done in 2016.1 FT, see this post. To do it in older versions, inherit from system classes.
Alternatively you can define a persistent class with properties of required types and transform it into json.
P.S. As a hack: JSON consumer can sometimes accept 1/0 in place of true/false, so you can try to use this values.
I modified your code like this:
Class test.DummyClass Extends %RegisteredObject
{
Property notanumber As %String;
Property aboolean As %Boolean;
/// do ##class(test.DummyClass).Test()
ClassMethod Test()
{
set dummy = ..%New()
set dummy.notanumber = "28001"
set dummy.aboolean = 1
do ##class(%ZEN.Auxiliary.jsonProvider).%ObjectToJSON(dummy,,,"aelotw")
}
}Terminal output:
>do ##class(test.DummyClass).Test()
{
"notanumber":"28001",
"aboolean":true
}Thank you.
I had a similar problem. The task was to write custom logging system, which would automatically store current method argument values. Here's how I done it.
First the the persistent log class (relevant parts):
Class App.Log Extends %Persistent
{
/// Replacement for missing values
Parameter Null = "Null";
/// Type of event
Property EventType As %String(MAXLEN = 10, VALUELIST = ",NONE,FATAL,ERROR,WARN,INFO,STAT,DEBUG,RAW") [ InitialExpression = "INFO" ];
/// Name of class, where event happened
Property ClassName As %String(MAXLEN = 256);
/// Name of method, where event happened
Property MethodName As %String(MAXLEN = 128);
/// Line of int code
Property Source As %String(MAXLEN = 2000);
/// Cache user
Property UserName As %String(MAXLEN = 128) [ InitialExpression = {$Username} ];
/// Arguments' values passed to method
Property Arguments As %String(MAXLEN = 32000, TRUNCATE = 1);
/// Date and time
Property TimeStamp As %TimeStamp [ InitialExpression = {$zdt($h, 3, 1)} ];
/// User message
Property Message As %String(MAXLEN = 32000, TRUNCATE = 1);
/// User IP address
Property ClientIPAddress As %String(MAXLEN = 32) [ InitialExpression = {..GetClientAddress()} ];
/// Add new log event
/// Use via $$$LogEventTYPE().
ClassMethod AddRecord(ClassName As %String = "", MethodName As %String = "", Source As %String = "", EventType As %String = "", Arguments As %String = "", Message As %String = "")
{
Set record = ..%New()
Set record.Arguments = Arguments
Set record.ClassName = ClassName
Set record.EventType = EventType
Set record.Message = Message
Set record.MethodName = MethodName
Set record.Source = Source
Do record.%Save()
}
}
And here's macros for client code:
#define StackPlace $st($st(-1),"PLACE")
#define CurrentClass ##Expression($$$quote(%classname))
#define CurrentMethod ##Expression($$$quote(%methodname))
#define MethodArguments ##Expression(##class(App.Log).GetMethodArguments(%classname,%methodname))
#define LogEvent(%type, %message) Do ##class(App.Log).AddRecord($$$CurrentClass,$$$CurrentMethod,$$$StackPlace,%type,$$$MethodArguments,%message)
#define LogNone(%message) $$$LogEvent("NONE", %message)
#define LogError(%message) $$$LogEvent("ERROR", %message)
#define LogFatal(%message) $$$LogEvent("FATAL", %message)
#define LogWarn(%message) $$$LogEvent("WARN", %message)
#define LogInfo(%message) $$$LogEvent("INFO", %message)
#define LogStat(%message) $$$LogEvent("STAT", %message)
#define LogDebug(%message) $$$LogEvent("DEBUG", %message)
#define LogRaw(%message) $$$LogEvent("RAW", %message)Now, how that works in client code? Let's say there is a class:
Include App.LogMacro
Class App.Use [ CompileAfter = App.Log ]
{
/// Do ##class(App.Use).Test()
ClassMethod Test(a As %Integer = 1, ByRef b = 2)
{
$$$LogWarn("Message")
}
}
In the int code, the $$$LogWarn macro would be transformed into:
Do ##class(App.Log).AddRecord("App.Use","Test",$st($st(-1),"PLACE"),"WARN","a="_$g(a,"Null")_"; b="_$g(b,"Null")_";", "Message")And after execution a new record would be added to App.Log table (note, that the method was called with default params - if it was called with other values they would be saved, as this logging system gets arguments values at runtime):
There is also some additional functionality, such as objects serializationinto json and context restoration at a later date, but that does not pertrain to the current discussion.
Anyway, the main idea is that at compile time we have a macro that:
Gets method arguments list from %Dictionary.CompiledMethod
For each argument decides on a strategy on how to get it's value at runtime
Writes source code that would implement value get at runtime
Builds code to get all method arguments values
Inserts this code into method
Relevant methods (in App.Log):
/// Entry point to get method arguments string
ClassMethod GetMethodArguments(ClassName As %String, MethodName As %String) As %String
{
Set list = ..GetMethodArgumentsList(ClassName,MethodName)
Set string = ..ArgumentsListToString(list)
Return string
}
/// Get a list of method arguments
ClassMethod GetMethodArgumentsList(ClassName As %String, MethodName As %String) As %List
{
Set result = ""
Set def = ##class(%Dictionary.CompiledMethod).%OpenId(ClassName _ "||" _ MethodName)
If ($IsObject(def)) {
Set result = def.FormalSpecParsed
}
Return result
}
/// Convert list of method arguments to string
ClassMethod ArgumentsListToString(List As %List) As %String
{
Set result = ""
For i=1:1:$ll(List) {
Set result = result _ $$$quote($s(i>1=0:"",1:"; ") _ $lg($lg(List,i))_"=")
_ ..GetArgumentValue($lg($lg(List,i)),$lg($lg(List,i),2))
_$S(i=$ll(List)=0:"",1:$$$quote(";"))
}
Return result
}
ClassMethod GetArgumentValue(Name As %String, ClassName As %Dictionary.CacheClassname) As %String
{
If $ClassMethod(ClassName, "%Extends", "%RegisteredObject") {
// it's an object
Return "_##class(App.Log).SerializeObject("_Name _ ")_"
} Else {
// it's a datatype
Return "_$g(" _ Name _ ","_$$$quote(..#Null)_")_"
}
}
The project is open-sourced and availible on GitHub (to use import all classes from App package into any namespace).
If you paste table from somewhere else, when creating a post, sometimes borders may be undisplayed. To fix that switch into HTML view (via "Disable rich-text" button) and find the beginning of your table definition. It would look somewhat like that:
<table class="confluenceTable">
And replace it with:
<table border="1" cellpadding="1" cellspacing="1">
Reading it now. Intresting. Thank you.
_____
| LLL |
Have you thought about uploading this projects on GitHub?
UPD. Nevermind, seen your message about GitHub in another topic.
Please upload these samples on GitHub.